#4278 closed New feature (fixed)
get_template should accept a dirs argument
Reported by: | amcnabb | Owned by: | Berker Peksag |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | tplrf-patched |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The function django.template.loader.find_template_source already accepts a dirs argument, which makes it possible to override TEMPLATE_DIRS. However, get_template and other functions are not aware of find_template_source's dirs argument. The attached patch adds this dirs argument, with a default value of None, to a few additional functions.
After applying the patch, I can do:
render_to_response('some_template_file.html', dirs=(SOME_OTHER_DIRECTORY,))
Attachments (2)
Change History (18)
by , 18 years ago
Attachment: | loader.diff added |
---|
comment:1 by , 18 years ago
Summary: | get_template should accept a dirs argument → [patch] get_template should accept a dirs argument |
---|
comment:2 by , 18 years ago
Summary: | [patch] get_template should accept a dirs argument → get_template should accept a dirs argument |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
comment:6 by , 14 years ago
Triage Stage: | Design decision needed → Accepted |
---|
Definitely a good idea in principle. The patch might well need refreshing, but the concept is sound.
comment:7 by , 14 years ago
Needs documentation: | set |
---|---|
Needs tests: | set |
comment:8 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:11 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:12 by , 11 years ago
Needs documentation: | unset |
---|---|
Needs tests: | unset |
I've opened a pull request on GitHub: https://github.com/django/django/pull/1632
comment:13 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:14 by , 10 years ago
The new dirs
parameters doesn't quite behave like I expected because dirs
is only used to find the top level template. If the template has an include tag, it reverts to the template directories listed in TEMPLATE_DIRS and does not use the directories listed in dirs
.
comment:15 by , 10 years ago
I'm also finding the change weird.
For instance, when the dirs parameter is passed, the app_directories
loader starts behaving like the filesystem
template loader, while the eggs
template loader ignores it entirely. It looks like this ticket doesn't account for template loaders other than filesystem
.
Sounds like a fairly good idea.