[Answered ]-Django querysets using __lte

1👍

Yes, you can use:

from django.db.models import Q

def get_rating_average(self, type):
    return super().aggregate(result=Avg(type))['result']

def filter_rating_average_under(self, type):
    return super().filter(
        Q((f'{type}__lte', self.get_rating_average(type=type)))
    )

Leave a comment