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 <[email protected]>
> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<django-users%[email protected]>
> .
> 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.