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 <law...@au-kbc.org>

> 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 where the handicap
> is
> at Max value. Is there a simpler way of doing this?
>
> --
> regards
> Kenneth Gonsalves
> Senior Project Officer
> NRC-FOSS
> http://nrcfosshelpline.in/web/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to