A content block is a named region in a shared HTML template. Child templates fill that region while the surrounding structure—such as the title, header, and footer—stays reusable. section 7.3.2 section 7.2
Use a content block to:
- Keep common page markup in one parent template instead of copying it into every page. section 7.3.2
- Let each child template supply its own form, results, or other page-specific HTML. section 7.2
- Connect templates through inheritance with {% extends ... %} and {% block content %}. section 7.2
A quiz page fills the content block
The parent template defines {% block content %}{% endblock %}. A child template extends the parent and places its question, answer choices, and submit button between {% block content %} and {% endblock %}. The same layout can then render a different results page without duplicating the outer HTML.
{% extends 'base.html' %}
{% block content %}
<h1>{{ question[2] }}</h1>
<form method="post">
<input type="radio" name="answer"
value="{{ question[3] }}">{{ question[3] }}</input><br>
<input type="radio" name="answer"
value="{{ question[4] }}">{{ question[4] }}</input><br>
<input type="radio" name="answer"
value="{{ question[5] }}">{{ question[5] }}</input><br>
<input type="radio" name="answer"
value="{{ question[6] }}">{{ question[6] }}</input><br>
<input type="submit" value="Submit">
</form>
{% endblock %}
Inspect a complete child template that inherits a parent and fills the content block with dynamic question data and a form. section 7.2
