On 11/4/07, Brot <[EMAIL PROTECTED]> wrote:
>
> >
> > partner_list = [ep.partner for ep in Event.objects.latest
> > ('date').eventpartner_set.all()]
>
> Ok, that works! But there is another problem now. I would like to sort
> the list of partners.
> The sort-criteria should be a field from the partner model. e.g: name
> Is this possible?
>

Sure, check out http://wiki.python.org/moin/HowTo/Sorting for lots of
examples on how to sort.  I think either

partner_list.sort(lambda x,y: cmp(x.name, y.name))

or (if using Python 2.4 or higher)

import operator
partner_list.sort(key=operator.attrgetter('name'))

would do what you're looking for.

Karen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to