> > Creating a template tag [1] might be a good idea here, especially if > you will be displaying a list of events on any other pages. > > In your view, you would have: > > future_events = > Event.objects.filter(start_date__gte=now).sort_by('start_date') > return render_to_response('clubs/events.html', {'events': > future_events}) > > And in the template, you would have: > > {% show_events events "Pacific" %} > {% show_events events "Central" %} > ... > > Or take out some more duplication: > > view: > > future_events = > Event.objects.filter(start_date__gte=now).sort_by('start_date') > regions = ["Pacific", "Central", ... ] > return render_to_response('clubs/events.html', { > 'events': future_events, > 'regions': regions}) > > template: > > {% for region in regions %} > {% show_events events region %} > {% endfor %} > > Now, you can do what you want with your newly created show_events > template tag. You could make the region optional, for example, and > display all events in the passed QuerySet if no region is specified. > > Also, if you aren't doing anything more in your view than passing the > couple of context variables to the template, you could even get rid of > your view entirely by using the direct_to_template generic view [2] > instead. > > [1]http://www.djangoproject.com/documentation/templates_python/#writing-... > [2]http://www.djangoproject.com/documentation/generic_views/#django-view... > > Gary
Thanks Gary, but it's just one page, and a fairly specialized one... although I left it out of the above code, there's also a form to submit events, and the template creates calendars for them. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---