[Fixed]-Django ORM for select max(field1) from table group by (field2);

1👍

This query should work for you

Transition.objects.values('instance').annotate(Max('id'))

docs : https://docs.djangoproject.com/en/1.8/topics/db/aggregation/

Leave a comment