Unlike the render_to_response shortcut, generic views only accepts a
single template name, not a list of templates.

These views could be improved by accepting multiple templates and the
compatibility wouldn't be affected.

One reason that this could be useful: having a categorized news
listing that may need different templates for each category or
fallback to a default template if the custom isn't found. Something
like this:

from django.views.generic.list_detail import object_list
from news.models import Entry

def news_by_category(request, slug, **kwargs):
    kwargs['template_name'] = ('news/%s/entry_list.html' % slug, 'news/
entry_list.html')
    kwargs['queryset'] = Entry.objects.filter(category__slug=category)
    return object_list(request, **kwargs)

Does anyone have interest on this?
Django 1.2 will have class-based generic views, should they accept
multiple templates?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to