[Answer]-Django max based on foreign key queryset

1👍

Use a values clause to group prior to annotating.

qs = B.objects.values('a').annotate(max_value=Max('value'))

Leave a comment