[Django]-ProgrammingError: when using order_by and distinct together in django

10👍

PostgreSQL is asking you to do this:

ProductScore.objects.filter(client=request.user).order_by('scale', '-created').distinct('scale')

…ordering by -created will give you the most recent of each duplicate, though your overall query results will be ordered by scale field

Leave a comment