typogrify icon indicating copy to clipboard operation
typogrify copied to clipboard

Jinja2 required for Django 1.9

Open evenicoulddoit opened this issue 9 years ago • 6 comments

Unless Jinja2 is pip installed, I get the following error on Django 1.9:

django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load 'typogrify.templatetags.jinja_filters': No module named jinja2

Didn't have Jinja2 installed previously and was working fine on Django 1.8

evenicoulddoit avatar Jan 05 '16 16:01 evenicoulddoit

+1

davejacobs avatar Jan 28 '16 04:01 davejacobs

happy to accept pull requests :) I'm not currently actively working on any django projects and haven't updated anything to 1.9 yet.

chrisdrackett avatar Jan 28 '16 19:01 chrisdrackett

I've run into this too. It's coming from the templatetags.jinja_filters, in the import jinja2 line. The part I don't understand is why 1.9 is attempting to load that tag at all. There's either a bug in 1.9, or something very poorly documented.

tBaxter avatar Jan 28 '16 22:01 tBaxter

I believe this is a defect in Django: https://code.djangoproject.com/ticket/26164

tBaxter avatar Feb 01 '16 22:02 tBaxter

This is a backwards-incompatible change in Django 1.9 as described in the release notes: https://github.com/django/django/commit/655f52491505932ef04264de2bce21a03f3a7cd0

In the template tag file you can add something like:

try:
   import jinja2
except ImportError:
   jinja2 = None

and raise an error later when using the template tag if jinja2 is needed and not installed.

timgraham avatar Feb 01 '16 23:02 timgraham

Thanks. Not actually my project, I just thought it illustrated the behavior well. I still disagree this is desirable, but can see the reasons to do it. I do think further documentation is in order on the behavior and how to mitigate unwanted side effects, and would like to propose an exclude_tags template setting that would allow one to block problematic tag loading as needed.

Sent from my iPhone

On Feb 1, 2016, at 5:24 PM, Tim Graham [email protected] wrote:

This is a backwards-incompatible change in Django 1.9 as described in the release notes: django/django@655f524

In the template tag file you can add something like:

try: import jinja2 except ImportError: jinja2 = None and raise an error later when using the template tag if jinja2 is needed and not installed.

— Reply to this email directly or view it on GitHub.

tBaxter avatar Feb 02 '16 00:02 tBaxter