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

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPM-O%2BzTen4Dw6KrNFr2HGEKE%2BMFa8_N149rewXxa9YeoKtNeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to