Django - 过滤字段大于限制值的对象
Django - Filter for objects with field that is bigger than limit value
我想筛选 ID 大于我指定的对象。
这就是我要找的:
const LIMIT_ID = 100
bigIdPeople = Person.objects.filter(id > LIMIT_ID)
这可能吗?我应该怎么做?
谢谢!
你可以这样做:
bigIdPeople = Person.objects.filter(id_gte=LIMIT_ID)
# this means 'greater than or equal to'
# if you want 'greater than', you can change 'gte' to 'gt'.
我想筛选 ID 大于我指定的对象。
这就是我要找的:
const LIMIT_ID = 100
bigIdPeople = Person.objects.filter(id > LIMIT_ID)
这可能吗?我应该怎么做? 谢谢!
你可以这样做:
bigIdPeople = Person.objects.filter(id_gte=LIMIT_ID)
# this means 'greater than or equal to'
# if you want 'greater than', you can change 'gte' to 'gt'.