Code

Opened 7 years ago

Closed 6 years ago

#4250 closed (wontfix)

Allow passing a list of templates into object_detail generic view

Reported by: adamfast@… Owned by: nobody
Component: Template system Version: master
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

It would be handy to allow a list of templates to be passed into a generic view, and then use the select_template function to find the first one retrievable. This way customized templates can be used in some instances, but it can always fall back to the "django default" for items that are not set.

Attachments (3)

allow-lists-for-templates.patch.rtf (1.1 KB) - added by adamfast@… 7 years ago.
Patch to django/views/generic/list_detail.py
allow-lists-for-templates.patch (1.5 KB) - added by adamfast@… 7 years ago.
allow lists for templates.patch
allow-lists-for-templates.2.patch (1.8 KB) - added by adamfast@… 7 years ago.
Patch to django/views/generic/list_detail.py and django/template/loader.py

Download all attachments as: .zip

Change History (8)

Changed 7 years ago by adamfast@…

Patch to django/views/generic/list_detail.py

comment:1 Changed 7 years ago by adamfast@…

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 years ago by adamfast@…

  • Has patch unset

Wait, this breaks things....I'll do some more research and see what can be done to keep current functionality yet add this.

Changed 7 years ago by adamfast@…

allow lists for templates.patch

Changed 7 years ago by adamfast@…

Patch to django/views/generic/list_detail.py and django/template/loader.py

comment:3 Changed 7 years ago by adamfast@…

  • Has patch set

Ok, bug fixed now. The only "assumption" it makes is that if the value of a template being passed in is a single character, it isn't a valid template. This catches the instance where a plain string is passed in (as has always been the behavior in the past) and it's accessed character-by-character as a list. It also does the same check when an error is raised to ensure the template it was looking for is displayed correctly.

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

  • Needs documentation set
  • Triage Stage changed from Unreviewed to Design decision needed

comment:5 Changed 6 years ago by lukeplant

  • Resolution set to wontfix
  • Status changed from new to closed
  • This makes select_template() rather crufty to handle a change in API of a completely different function -- really not nice.
  • When calling a generic view, I imagine that normally you know what template you want to use.
  • There is already a mechanism for 'shadowing' templates by using template directories appropriately.
  • You can work around this without patching Django by doing some kind of 'select_template' call before hand and working out which template is returned, then specifying that one.

So, I'm closing WONTFIX

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.