[Fixed]-Jinja2 templates a superset of Django templates?

15👍

No, Jinja is not a strict superset of the Django Template Language. A good summary of the differences is given in the Jinja documentation.

There’s no particular reason why Jinja would be a superset of the DTL. It’s meant as a stand-alone package that can be used by any Python web framework. I would say that most of the differences are due to Jinja’s attempt to be less restrictive and more Pythonic than the DTL. For example, while Jinja filter syntax uses the usual function call parentheses, the DTL uses a combination of | and :. (The DTL has slowly changed over time and is a bit more Pythonic than it used to be.)

Jinja is officially supported by Django, and even before that there were third-party packages that allowed you to use it. The only real compatibility issue is that you can’t use Django’s custom template tags in a Jinja template. That could come up if you were using Jinja for your template language but wanted to use a third-party package that that provided functionality with a custom template tag.

7👍

Django to Jinja2 templates are slightly different in method calls, condition, filter arguments and test are slightly different

Well most of the syntax elements look and work the same.

Example in Django template:

{% for page in user.get_created_pages %}<br/>
    <br/>
{% endfor %}

will be this in Jinja:

{% for page in user.get_created_pages() %}<br/>
    <br/>
{% endfor %}

Leave a comment