Re: Retrieving other fields along with ValueQueryset

2014-11-12 Thread Collin Anderson
Hello, I feel like this sort of query comes up a lot and there isn't a good solution. One option would be to somehow do a _second_ query that gets all of the Batting objects for each of the year, score pairs. Or, you could a query for each year and sort by score. Or, it might be possible to g

Re: Retrieving other fields along with ValueQueryset

2014-11-02 Thread Joel Goldstick
Using v1.6 On Sun, Nov 2, 2014 at 2:18 PM, Joel Goldstick wrote: > 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')) > > Bu

Retrieving other fields along with ValueQueryset

2014-11-02 Thread Joel Goldstick
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 na