Opened 17 years ago

Closed 17 years ago

#3667 closed (wontfix)

Useful optional argument for generic views

Reported by: sasch.pe@… Owned by: Jacob
Component: Generic views Version: dev
Severity: Keywords: Optional Arguments, Date-Based
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Malcolm Tredinnick)

Hello everybody, i played a bit with generic views and thought, that it would be useful to have a 'template_base' optional argument. If you want to pass a custom template to a generic view, you currently have to add a 'template_name' argument to the parameter dictionary. For example, i have an app called 'blog' with a template-folder inside, Django has no problem with that, but the default generic views want to see my html-files in 'blog/templates/blog/'. So, when i provide something like this:

info_dict = {
    'queryset' : Spam.objects.all(),
    'date_field' : 'pub_date',
}

i would like to have that:

info_dict = {
    'queryset' : Spam.objects.all(),
    'date_field' : 'pub_date',
    'template_base' : 'templates',
}

This would simplyfy my URLconfs, currently if have to do a

     ...
     dict(blog_dict,template_name='Spam.html'),
     ...

in every URLconf. Maybe you could give it a tought.

Change History (2)

comment:1 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedDesign decision needed

comment:2 by Malcolm Tredinnick, 17 years ago

Description: modified (diff)
Resolution: wontfix
Status: newclosed

This just seems to be a different way of achieving what can already be done using template_name. If you want slightly different syntax, you can wrap the generic view calls in your own function or class (with a __call__ method) and use that.

Note: See TracTickets for help on using tickets.
Back to Top