Home > other >  Django - Filter for objects with field that is bigger than limit value
Django - Filter for objects with field that is bigger than limit value

Time:10-12

I want to filter for objects whose id is bigger than one that I've specified.

This is what I am looking for:

const LIMIT_ID = 100

bigIdPeople = Person.objects.filter(id > LIMIT_ID)

Is this possible and how should I do this? Thank you!

CodePudding user response:

You can do like this:

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'.
  • Related