Source

django-in-a-box / docs / tools / jinja2.md

Full commit

Jinja2

Jinja2 is a fast and simple templating system for Python. It has a syntax based on Django’s built-in templating system, but gives you a bit more expressive power and flexibility. With this power, however, comes responsibility; you should always try to constrain your heavy business logic to your view functions.

Nevertheless, if you use it right, it can be a powerful tool and can save you a lot of time and effort working around the constraints of the Django’s built-in templating system. Anyone who has ever had to type {% endifnotequal %} knows what that means.

DjanJinja

In order to integrate more closely with Jinja2, Django-in-a-Box includes DjanJinja, a Django application which provides several shortcuts and wrappers to make using Jinja2 feel more native within Django. To get started straight away, write your templates using Jinja2, putting them in the same location as usual. To render them from within your views:

from djanjinja.views import render_to_response

def myview(request):
    return render_to_response('template_name.txt', {'key': 'value'})

For more information, consult the DjanJinja documentation at its project page.