Django 单表的双下划线
############ # 单表的双下划线 models.Person.objects.filter(id__gt=4) # 大于 greater than models.Person.objects.filter(id__lt=4) # 小于 less than models.Person.objects.filter(id__get=4) # 大于等于 greater than equal models.Person.objects.filter(id__lte=4) # 小于等于 less than equal models.Person.objects.filter(id__range=[1,5]) # 范围 左右都包含 models.Person.objects.filter(id__in=[1,5]) # 成员判断 models.Person.objects.filter(name__contains='alex') # like models.Person.objects.filter(name__icontains='alex') # like 忽略大小写 models.Person.objects.filter(name__startswith='alex') # 以什么开头 models.Person.objects.filter(name__istartswith='alex') # 以什么开头 忽略大小写 models.Person.objects.filter(name__endseith='alex') # 以什么结尾 models.Person.objects.filter(name__iendseith='alex') # 以什么结尾 忽略大小写 models.Person.objects.filter(birth__year='2020') # models.Person.objects.filter(birth__contains='2020-02') # models.Person.objects.filter(name__isnull=True) # 字段是否为null
本文来自博客园, 作者:Star-Hitian, 转载请注明原文链接:https://www.cnblogs.com/Star-Haitian/p/15129387.html