Django 單表的雙下劃線
阿新 • • 發佈:2021-08-11
############ # 單表的雙下劃線 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