#12772: Allow loading template tags by fully qualified python module path
---------------------------------+------------------------------------
Reporter: patrys | Owner: patrys
Type: New feature | Status: assigned
Component: Template system | Version: 1.2-beta
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by mjtamlyn):
* cc: marc.tamlyn@… (added)
Comment:
While I approve of magic removal, I'm not convinced I like the idea of
importing by python path.
A possible solution to both any security concerns and namespace collisions
would be to have `TEMPLATE_TAG_LOADERS` - one with the automatic behaviour
which could be removed if you want to, and one which is configured via a
mapping of library names to dotted paths to python files.
So current (default) behaviour:
{{{TEMPLATE_TAG_LOADERS =
('django.template.tag_loaders.AppDirectoriesLoader',)}}}
Magic removal version:
{{{
TEMPLATE_TAG_LOADERS = ('django.template.tag_loaders.ConfiguredLoader',)
TEMPLATE_TAG_LIBRARIES = {
'admin.urls': 'django.contrib.admin.templatetags.admin_urls',
# ... other built in libraries
'my_tags': 'my_project.my_custom_templatetags',
}
}}}
These settings would actually not be yet more top level settings, but more
configuration settings within Aymeric's template engines branch, which
would make them a bit more palatable.
Not 100% sure this is a good idea, but I think it is worth considering.
Most people would continue to use the magical version we have, but it
would now be explicit, overridable magic.
--
Ticket URL: <https://code.djangoproject.com/ticket/12772#comment:28>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.a27e4ae3b5d1b744033617a186dfd33b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.