I'm sure you all will immediately see what I'm doing, and how I could
be doing it better. I'm sure I need to create my own dict or
something, but I'm not sure how I'd do so, or (more importantly), how
I'd work with in the template.

In my view, I have:
future_events = Event.objects.filter(start_date__gte=now)
    pacific_events = future_events.filter(club__region='Pacific')
    rocky_mountain_events = future_events.filter(club__region='Rocky
Mountain')
    southwest_events = future_events.filter(club__region='Southwest')
    midwest_events = future_events.filter(club__region='Midwest')
    central_events = future_events.filter(club__region='Central')
    northeast_events =
future_events.filter(club__region='Northeast')
    southeast_events =
future_events.filter(club__region='Southeast')

    return render_to_response('clubs/events.html', {'
        'pacific_events': pacific_events,
        'rocky_mountain_events':rocky_mountain_events,
        'southwest_events':southwest_events,
        'midwest_events':midwest_events,
        'central_events':central_events,
        'northeast_events':northeast_events,
        'southeast_events':southeast_events,
    })

And then in the view, I spit out:
{% if pacific_events %}
      do stuff
{% endif %}

For each event type, ad nauseum. It works, but I know I'm being stupid
here and thoroughly violating the DRY principle. Could someone show me
the light?


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