Django -过滤字段大于限制值的对象



我想过滤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'.

最新更新