Login

Snippets by SimonSapin

Snippet List

Django 1.2+ template loader for Jinja2

This is a minimal template loader for Django 1.2 or higher that loads [Jinja2](http://jinja.pocoo.org/2/) 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](http://jinja.pocoo.org/2/documentation/) for more details.

  • template
  • jinja
  • jinja2
  • django1.2
Read More

SimonSapin has posted 1 snippet.