Code

Opened 7 years ago

Closed 7 years ago

#3667 closed (wontfix)

Useful optional argument for generic views

Reported by: sasch.pe@… Owned by: jacob
Component: Generic views Version: master
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: UI/UX:

Description (last modified by mtredinnick)

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.

Attachments (0)

Change History (2)

comment:1 Changed 7 years ago by Simon G. <dev@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 7 years ago by mtredinnick

  • Description modified (diff)
  • Resolution set to wontfix
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.