From 960d7aa57565c6ef78460784859ded7557326574 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Thu, 3 Dec 2015 15:31:58 +0000 Subject: [PATCH] feat(django 1.9): Move jinja2 tags out of templatetags folders Django 1.9 now automatically imports all models in templatetags. This causes ImportErrors to be raised for users who do not have jinja2 installed. --- docs/advanced_topics/jinja2.rst | 10 +++++++--- wagtail/tests/settings.py | 6 +++--- .../{templatetags/jinja2.py => jinja2tags.py} | 2 +- .../{templatetags/jinja2.py => jinja2tags.py} | 2 +- .../{templatetags/jinja2.py => jinja2tags.py} | 0 5 files changed, 12 insertions(+), 8 deletions(-) rename wagtail/wagtailadmin/{templatetags/jinja2.py => jinja2tags.py} (88%) rename wagtail/wagtailcore/{templatetags/jinja2.py => jinja2tags.py} (86%) rename wagtail/wagtailimages/{templatetags/jinja2.py => jinja2tags.py} (100%) diff --git a/docs/advanced_topics/jinja2.rst b/docs/advanced_topics/jinja2.rst index 9ec5c66e5a..fa15d4b4d5 100644 --- a/docs/advanced_topics/jinja2.rst +++ b/docs/advanced_topics/jinja2.rst @@ -9,6 +9,10 @@ Wagtail supports Jinja2 templating for all front end features. More information Configuring Django ================== +.. versionchanged:: 1.3 + + Jinja2 tags were moved from "templatetags" into "jinja2tags" to separate them from Django template tags. + Django needs to be configured to support Jinja2 templates. As the Wagtail admin is written using regular Django templates, Django has to be configured to use both templating engines. Wagtail supports the Jinja2 backend that ships with Django 1.8 and above. Add the following configuration to the ``TEMPLATES`` setting for your app: .. code-block:: python @@ -20,9 +24,9 @@ Django needs to be configured to support Jinja2 templates. As the Wagtail admin 'APP_DIRS': True, 'OPTIONS': { 'extensions': [ - 'wagtail.wagtailcore.templatetags.jinja2.core', - 'wagtail.wagtailadmin.templatetags.jinja2.userbar', - 'wagtail.wagtailimages.templatetags.jinja2.images', + 'wagtail.wagtailcore.jinja2tags.core', + 'wagtail.wagtailadmin.jinja2tags.userbar', + 'wagtail.wagtailimages.jinja2tags.images', ], }, } diff --git a/wagtail/tests/settings.py b/wagtail/tests/settings.py index cf4f36055d..9e54235557 100644 --- a/wagtail/tests/settings.py +++ b/wagtail/tests/settings.py @@ -62,9 +62,9 @@ if django.VERSION >= (1, 8): 'APP_DIRS': True, 'OPTIONS': { 'extensions': [ - 'wagtail.wagtailcore.templatetags.jinja2.core', - 'wagtail.wagtailadmin.templatetags.jinja2.userbar', - 'wagtail.wagtailimages.templatetags.jinja2.images', + 'wagtail.wagtailcore.jinja2tags.core', + 'wagtail.wagtailadmin.jinja2tags.userbar', + 'wagtail.wagtailimages.jinja2tags.images', ], }, }, diff --git a/wagtail/wagtailadmin/templatetags/jinja2.py b/wagtail/wagtailadmin/jinja2tags.py similarity index 88% rename from wagtail/wagtailadmin/templatetags/jinja2.py rename to wagtail/wagtailadmin/jinja2tags.py index 5bcc1a05a0..bb5bb276bf 100644 --- a/wagtail/wagtailadmin/templatetags/jinja2.py +++ b/wagtail/wagtailadmin/jinja2tags.py @@ -3,7 +3,7 @@ from __future__ import absolute_import import jinja2 from jinja2.ext import Extension -from .wagtailuserbar import wagtailuserbar +from .templatetags.wagtailuserbar import wagtailuserbar class WagtailUserbarExtension(Extension): diff --git a/wagtail/wagtailcore/templatetags/jinja2.py b/wagtail/wagtailcore/jinja2tags.py similarity index 86% rename from wagtail/wagtailcore/templatetags/jinja2.py rename to wagtail/wagtailcore/jinja2tags.py index 7c10132f08..7d25585bf2 100644 --- a/wagtail/wagtailcore/templatetags/jinja2.py +++ b/wagtail/wagtailcore/jinja2tags.py @@ -3,7 +3,7 @@ from __future__ import absolute_import import jinja2 from jinja2.ext import Extension -from .wagtailcore_tags import pageurl, richtext, slugurl, wagtail_version +from .templatetags.wagtailcore_tags import pageurl, richtext, slugurl, wagtail_version class WagtailCoreExtension(Extension): diff --git a/wagtail/wagtailimages/templatetags/jinja2.py b/wagtail/wagtailimages/jinja2tags.py similarity index 100% rename from wagtail/wagtailimages/templatetags/jinja2.py rename to wagtail/wagtailimages/jinja2tags.py