pythondjangofilterdjango-queryset

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


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!


Solution

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