Introduction
Django templates come equipped with a robust system of tags and filters, offering powerful tools to manipulate and display data in a flexible manner. This documentation provides insights into the effective use of template tags and filters.
Template Tags
Looping through Data
{% for item in items %}{{ item }}
{% endfor %}
Conditional Statements
{% if condition %}<p>This is displayed if the condition is true.</p>
{% else %}<p>This is displayed if the condition is false</p>
{% endif %}
Including Other Templates
{% include 'header.html' %}
Template Filters
String Filters
{{ variable|lower }}
{{ date_variable|date:"F d, Y" }}
Numerical Filters
{{ number_variable|add:5 }}
Combining Tags and Filters
{% for item in items %}<p>{{ item.name|title }} - {{ item.price|currency }}</p>
{% endfor %}