>>    future_events = Event.object.filter(
>>      start_date__gte=now).select_related(
>>      ).order_by('start_date')
>>
>>    events = {} # or SortedDict if order matters
>>    for event in future_events:  # one DB hit here
>>      region = event.club.region
>>      ev_list = events.get(region, [])
>>      ev_list.append(event)
>>      events[region] = ev_list
>>    return render_to_response(..., {
>>      'events': events, # this might need to
>>         # be events.iteritems() or something
>>         # like that
>>      ...})
>>
>
> I'm probably doing something wrong in my template now, but that
> version is only returning one event per region, and the order is
> backwards. I tried .order_by('-start_date'), but it didn't appear to
> make any difference.

(fixed top-posting)

Not having your models, I've only been guessing at them which may 
be causing problems.

Before the "return render_to_response(...)" line, you might want 
to try adding one of the following

   assert False, repr(events)
   assert False, repr(events.items())

to see what comes back.

-tim




--~--~---------~--~----~------------~-------~--~----~
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