I have a model with a year field and a score field, as well as other
fields. I want to get the highest score for each year. I can do that
with this:
Batting.objects.values('year').annotate(category=Max('score'))
But I also want to display the the name associated with the highest
score. The name is in a table that is linked by a foreign key. My
results contain only the year and the Max value.
How can I get the name in my queryset but still group by year only?
--
Joel Goldstick
http://joelgoldstick.com