实训第八天 有关python orm 的学习记录 常用方法02
继续沿用第七天数据库:def test2(request):
# 1.xxx__lt 小于 :查询出年龄小于22的所有 ret=models.Person.objects.filter(age__lt=22) print(ret)
# 2.xxx__lte 小于等于
ret=models.Person.objects.filter(age__lte=22)
print(ret)
# 3.xxx__gt 大于: ret = models.Person.objects.filter(age__gt=21)print(ret)
# 4.xxx__gte 大于等于:
ret = models.Person.objects.filter(age__gte=21)
print(ret)
# 5.xx__in=[] 包含某些值 ret = models.Person.objects.filter(age__in=[21, 23, 33])print(ret)
# 6.xx__contains= 包含内容
ret = models.Person.objects.filter(name__contains=‘l‘)
print(ret)
# 7.xxx__startswith= 查询出以某个字符 开始的对象 ret = models.Person.objects.filter(name__startswith=‘l‘)print(ret)
# 8.xx__endswitn= 查询出以 某个字符串结束的对象
ret = models.Person.objects.filter(name__endswith=‘x‘)print(ret)
return HttpResponse(‘第八天的常用方法___双下划线方法‘)
相关推荐
YENCSDN 2020-11-17
lsjweiyi 2020-11-17
houmenghu 2020-11-17
Erick 2020-11-17
HeyShHeyou 2020-11-17
以梦为马不负韶华 2020-10-20
lhtzbj 2020-11-17
夜斗不是神 2020-11-17
pythonjw 2020-11-17
dingwun 2020-11-16
lhxxhl 2020-11-16
坚持是一种品质 2020-11-16
染血白衣 2020-11-16
huavhuahua 2020-11-20
meylovezn 2020-11-20
逍遥友 2020-11-20
weiiron 2020-11-16