1👍
✅
Use a values
clause to group prior to annotating.
qs = B.objects.values('a').annotate(max_value=Max('value'))
Source:stackexchange.com