HOWTO: getting distinct rows using Django ORM

less than 1 minute read

Pretty simple:

Author.objects.values('surname').distinct()

You have a list of all authors with no duplication.
If you use .orderby() together with .values(), you’ll have to specify in the order a field that is in .values()

Any comment or suggestion are appreciate :)

Comments