Grokking Django
0% completed
Understanding Template Tags and Filters
A three-line snippet shows both features that this lesson covers:
{% if article %} <h2>{{ article.title|upper }}</h2> {% endif %}
The first line is a template tag. Tags are written between {% and %}, and they control what the template produces: they test conditions, repeat blocks, build URLs and include other files. The part after the pipe character, |upper, is a template filter. A filter takes the value on its left and changes it before it is shown, in this case into capital letters. For the article "Getting Started with Django", the heading renders as
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%