Django 1.2+ template loader for Jinja2

This is a minimal template loader for Django 1.2 or higher that loads Jinja2 templates. It is better integrated with Django than using Jinja2 directly:

Your view code is the same

Unmodified generic views use it

RequestContext and context processors still work

To use it, add the following to you settings.py file:

TEMPLATE_LOADERS = (
'jinja2_for_django.Loader',
)

It searches for templates in the same places as django.template.loaders.app_directories.Loader − that is in the templates directory of each installed app.

Django custom and default template tags and filters are not available. Some are the same in Jinja2, but you need to replace the others yourself. You can add global filters and variables (such as functions) in the Loader.env.filters and Loader.env.globals dicts. You can not add tags. See the Jinja2 documentation for more details.

Comments

Your setup may be different than mine, but I think you want to add settings.TEMPLATE_DIRS to app_template_dirs on line 29. Otherwise it seems that it will only load templates from the django module directories but not from your app.