Templates
Render data with the Django template language and template inheritance.
What you will be able to do
- Use {{ value }} for output and {% tag %} for logic.
- Extend a base template with blocks.
- Autoescaping is on by default.
- Avoid heavy logic in templates.
In plain English
Django templates are HTML with a small, deliberately limited language. Inheritance keeps layout in base.html and lets pages fill blocks. Autoescaping protects you from injected HTML; use |safe only for trusted content.
{% extends "base.html" %}
{% block content %}
<h1>{{ lesson.title }}</h1>
<p>{{ lesson.summary }}</p>
{% if lesson.minutes >= 15 %}
<span class="badge">Long lesson</span>
{% endif %}
{% endblock %}Your turn
EasyShow an empty state
Render a paragraph when the lessons list is empty.
HTML · starter
{% for lesson in lessons %}Check your understanding before moving on.
Knowledge checkQuestion 1
Is autoescaping enabled by default in Django templates?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.