Django less than and greater than 1

Django less than and greater than

# Less than or equal:
User.objects.filter(userprofile__level__lte=0)

#Greater than or equal:
User.objects.filter(userprofile__level__gte=0)

Here is what the above code is Doing:
1. We’re using the filter method to filter the User model.
2. We’re using the double underscore notation to access the level attribute of the UserProfile model.
3. We’re using the lte (less than or equal) lookup to filter the User model.

Similar Posts