To reproduce:
1. Start a fresh Django 1.9 project
2. pip install typogrify
3. Create a TemplateView URL, and in the template, simply have "Hello
world", with no blocks, no template loading, no nothing.
You will see "ImportError raised when trying to load
'typogrify.templatetags.jinja_filters': No module named jinja2"
Because jinja2 was never pip installed, of course. But Django is loading
https://github.com/mintchaos/typogrify/blob/master/typogrify/templatetags/jinja_filters.py
anyway.
I don't think an unwanted third-party app should be able to control the
environment. If this *is* actually desired or necessary, whether it makes
sense to me or not, I think some guidance for template tag writers and
site owners to mitigate downsides is in order
Reference: https://github.com/mintchaos/typogrify/issues/44
--
Ticket URL: <https://code.djangoproject.com/ticket/26164>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Maybe related to this commit:
https://github.com/django/django/commit/655f52491505932ef04264de2bce21a03f3a7cd0
--
Ticket URL: <https://code.djangoproject.com/ticket/26164#comment:1>
* status: new => closed
* resolution: => invalid
Comment:
Yes, this is intentional. See the section "Template tag modules are
imported when templates are configured" added in the backwards-
incompatible section of the 1.9 release notes in that commit.
--
Ticket URL: <https://code.djangoproject.com/ticket/26164#comment:2>
Comment (by tBaxter):
Respectfully, I think at the very least there's a documentation
improvement to be made here. The single sentence "Template tag modules are
imported when templates are configured" falls well short of describing the
current behavior, which was was surprising to many experienced Django devs
on #django IRC.
I understand that it is intentional, and whether or not I agree it's the
correct behavior isn't particularly relevant, but I'm trying to at least
minimize surprises and unwanted side-effects.
I would also like to propose a TEMPLATE['exclude_tags'] = () type setting
in which one could add filenames that should explicitly be blocked and
never loaded, if they are unwanted. I understand that could get a bit
messy and convoluted, but I wanted to float the idea.
--
Ticket URL: <https://code.djangoproject.com/ticket/26164#comment:3>
Comment (by timgraham):
Feel free to propose a documentation patch for the release notes.
Regarding the proposed setting, I think it's more convenient for users if
third-party apps adapt their code to raise errors lazily if they want the
old behavior rather than requiring users of the app to add certain
template tag modules to an exclude setting. Feel free to raise the
proposal on the DevelopersMailingList if you disagree.
--
Ticket URL: <https://code.djangoproject.com/ticket/26164#comment:4>