Until now, Jinja2 was my favorite template engine over Django 1.1's default templates. It provides more flexibility and performs much better.

However, if the website requires language translation support, Jinja2 sucks. Django has a nice automatic feature to collect all translations for a project by simply running:

django-admin.py makemessages -a

Then it's easy to edit the translation files of each language in locale/(language)/LC_MESSAGES/django.po and finally compile them with one command:

django-admin.py compilemessages

This is very simple and automatic, and everything is centralized in one file per language. But with Jinja2, it doesn't work any more, because Django's makemessages doesn't detect the Jinja2 templates. Apparently it's caused by Jinja2 choosing to use different template tags for translations than Django does.

There are some other problems with Jinja2 templates, too. They could pretty easily support most of Django's template tags, but for some reason choose not to. So you have to change {% blocktrans %} to {% trans %} and {% url proj.home.views.index %} into some custom tag you have to implement yourself, and so on. Close, but no cigar.

Jinja2 would be much more interesting if they were (even just 99%) backwards compatible with Django. That would allow an upgrade path from projects initially developed with Django templates and later needing a performance boost from Jinja2.

Published 29.9.2009