Re: getting the object with max value

2010-01-25 Thread Kenneth Gonsalves
On Monday 25 Jan 2010 3:25:51 pm Tomasz Zieliński wrote: > > I have a model 'Player' and a Model 'Handicap'. Handicap will have > > several fields, one of which is a foreign key to player. Now I need to > > get the Handicap instance when the player had the highest handicap. I can > > use Max to fin

Re: getting the object with max value

2010-01-25 Thread Dougal Matthews
model.objects.annotate(Max('handicap')).order_by('-handicap__max') I think something like that does what you need. Dougal --- Dougal Matthews - @d0ugal http://www.dougalmatthews.com/ 2010/1/25 Kenneth Gonsalves > hi, > > I have a model 'Player' and a Model 'Handicap'. Handicap will have sev

Re: getting the object with max value

2010-01-25 Thread Tomasz Zieliński
On 25 Sty, 07:38, Kenneth Gonsalves wrote: > hi, > > I have a model 'Player' and a Model 'Handicap'. Handicap will have several > fields, one of which is a foreign key to player. Now I need to get the > Handicap > instance when the player had the highest handicap. I can use Max to find the > high

getting the object with max value

2010-01-24 Thread Kenneth Gonsalves
hi, I have a model 'Player' and a Model 'Handicap'. Handicap will have several fields, one of which is a foreign key to player. Now I need to get the Handicap instance when the player had the highest handicap. I can use Max to find the highest handicap and do a query to identify the instance wh