Using Jinja2 Templates in Django

From Littledamien Wiki
Revision as of 05:44, 3 December 2015 by Video8 (talk | contribs) (Created page with "Category:Django Category:Web Development This is a useful link [http://jonathanchu.is/posts/upgrading-jinja2-templates-django-18-with-admin/ Upgrading to Jinja2 Templa...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This is a useful link Upgrading to Jinja2 Templates in Django 1.8 With Admin - jonathanchu.is

I managed to get this set up with the "northrose" project. Use that as reference.

|
+- jinja2/ << where I ultimately placed the jinja2 templates. It didn't work as documented under "templates"
|
+- mydjangoproject/
    |
    +- jinja.py << aliases for "url" and "static" defined here
    +- settings.py << jinja2 processor and environment set

TODO: document getting supporting url and static tags from Django templates.

Django convention: {% url "view-details" arg1 arg2 %}

Jinja2 convention: {{ url("view-details", args=[arg1, arg2, ]) }}, this is really an alias for Django's reverse() method, enclosed as a variable instead of as a tag.