Opened 18 years ago
Closed 16 years ago
#4250 closed (wontfix)
Allow passing a list of templates into object_detail generic view
Reported by: | 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)
Change History (8)
by , 18 years ago
Attachment: | allow-lists-for-templates.patch.rtf added |
---|
comment:1 by , 18 years ago
Has patch: | set |
---|
comment:2 by , 18 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 , 18 years ago
Attachment: | allow-lists-for-templates.patch added |
---|
allow lists for templates.patch
by , 18 years ago
Attachment: | allow-lists-for-templates.2.patch added |
---|
Patch to django/views/generic/list_detail.py and django/template/loader.py
comment:3 by , 18 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 , 18 years ago
Needs documentation: | set |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
comment:5 by , 16 years ago
Resolution: | → wontfix |
---|---|
Status: | new → 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
Patch to django/views/generic/list_detail.py