[Answer]-How to use Django ORM to make a query so that it returns the latest entry based on a datetime field in a particular group?

1👍

I use this in my own projects. The order_by and values make it group by name

from django.db import models
Model.objects.order_by('name').values('name').annotate(max_timestamp=models.Max("timestamp"))

Leave a comment