18๐
โ
Put your values
clause before the annotate
.
From the aggregation docs:
If the values() clause precedes the annotate(), the annotation will be computed using the grouping described by the values() clause.
However, if the annotate() clause precedes the values() clause, the annotations will be generated over the entire query set. In this case, the values() clause only constrains the fields that are generated on output.
So this should do it:
Meetup.objects.values('language').annotate(latest_date=Max('date'))
๐คPeter DeGlopper
Source:stackexchange.com