[Fixed]-Django queryset filter GT, LT, GTE, LTE returns full object list


As you said max possible score is 100 so it will always return all objects because lte means return all objects whose score is either less than or equal to 100. You might need lt lookup which means just return those objects whose score is less than 100:

filtered = all_objects.filter(score__lt=100)


You are saying that The max possible score is 100. By using score__lte=100, you are filtering all objects with score less than or equal to 100 – which is every object in the table by your own definition.


Leave a comment