Newbie question, yet I cannot find a sufficient step-by-step instruction on Jinja2 official website or by googling.
My current Django project is halfway done, and I cannot stand not able to use queryset filter in Django template anymore. So decide to switch to Jinja2.
What I have done: pip install jinja2 to the virtualenv. Then I tried to use Jinja syntax in my template files, which fails.. apparently and sadly
What else do I need to do to make Jinja2 work?
I just want to recommend two alternatives I find very useful.
One is the jinja template tag which lets you use jinja within django templates as
{% jinja %}{{ this_is_jinja(True)}}{% endjinja %}
Very useful when you can't / don't want to break the rest of your existing templates.
http://www.mellowmorning.com/2010/08/24/mixing-django-with-jinja2-without-losing-template-debugging/
The other is conditional loading of template engines based on filename (note I wrote this since I use both template languages):
https://github.com/yuchant/django-jinja2
You'll need to switch to using a rendering method that uses Jinja2 templates instead of Django templates - coffin has a helper you can use named render_to_response that should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With