If your DB is postgres which supports distinct()
on field you can try
Score.objects.order_by('student__username', '-date').distinct('student__username')
More Related Contents:
- Django Aggregation: Summation of Multiplication of two fields
- How to perform OR condition in django queryset?
- What’s the difference between select_related and prefetch_related in Django ORM?
- Django filter queryset __in for *every* item in list
- How can I filter a Django query with a list of values?
- Getting the SQL from a Django QuerySet [duplicate]
- How do I do a not equal in Django queryset filtering?
- Django Query That Get Most Recent Objects From Different Categories
- How to execute a GROUP BY … COUNT or SUM in Django ORM?
- How do I get the object if it exists, or None if it does not exist in Django?
- Django self-referential foreign key
- LEFT JOIN Django ORM
- Serializing Foreign Key objects in Django
- django – convert a list back to a queryset [duplicate]
- Django Blob Model Field
- Django values_list vs values
- many-to-many in list display django
- How to combine multiple querysets in Django?
- “_set” in a queryset object in Django
- aggregate() vs annotate() in Django
- Count() vs len() on a Django QuerySet
- Simple Subquery with OuterRef
- QuerySet, Object has no attribute id – Django
- Django custom annotation function
- django filter on the basis of text length
- What is the default order of a list returned from a Django filter call?
- Django filter JSONField list of dicts
- How to annotate Count with a condition in a Django queryset
- How to delete a record in Django models?
- Can a dictionary be passed to django models on create?