Django Template Language (DTL) ਦੀ ਵਰਤੋਂ HTML ਨੂੰ ਗਤੀਸ਼ੀਲ ਢੰਗ ਨਾਲ ਤਿਆਰ ਕਰਨ ਲਈ ਕੀਤੀ ਜਾਂਦੀ ਹੈ — templates HTML ਫਾਈਲਾਂ ਹਨ ਜਿਨ੍ਹਾਂ ਵਿੱਚ data ਨੂੰ insert ਕਰਨ, looping ਕਰਨ ਅਤੇ 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" }}
