Opened 17 years ago

Closed 16 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: dev
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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@… 17 years ago.
Patch to django/views/generic/list_detail.py
allow-lists-for-templates.patch (1.5 KB ) - added by adamfast@… 17 years ago.
allow lists for templates.patch
allow-lists-for-templates.2.patch (1.8 KB ) - added by adamfast@… 17 years ago.
Patch to django/views/generic/list_detail.py and django/template/loader.py

Download all attachments as: .zip

Change History (8)

by adamfast@…, 17 years ago

Patch to django/views/generic/list_detail.py

comment:1 by adamfast@…, 17 years ago

Has patch: set

comment:2 by adamfast@…, 17 years ago

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.

by adamfast@…, 17 years ago

allow lists for templates.patch

by adamfast@…, 17 years ago

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

comment:3 by adamfast@…, 17 years ago

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 by Simon G. <dev@…>, 17 years ago

Needs documentation: set
Triage Stage: UnreviewedDesign decision needed

comment:5 by Luke Plant, 16 years ago

Resolution: wontfix
Status: newclosed
  • 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

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