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/
Source:stackexchange.com