Django Template Language (DTL) का उपयोग HTML को गतिशील रूप से उत्पन्न करने के लिए किया जाता है — templates वे HTML files हैं जिनमें data डालने, loop करने, और conditionals के लिए विशेष syntax होता है। यह जानबूझकर templates में logic को सीमित करता है, presentation को business logic से अलग रखते हुए (जो views में होनी चाहिए)।
तीन मुख्य syntaxes
{{ article.title }}
Author: {{ article.author.name }}
{% if user.is_authenticated %}
Welcome, {{ user.username }}
{% else %}
Log in
{% endif %}
{% for article in articles %}
{{ article.title }}
{% empty %}
No articles yet.
{% endfor %}
{{ name|upper }}
{{ article.body|truncatewords:30 }}
{{ price|floatformat:2 }}
{{ date|date:"Y-m-d" }}
