Template Inheritance
Sounds complicated but is very basic. It’s easiest to understand it by startingwith an example.
In this example, the tags define four blocks that child templatescan fill in. All the block tag does is tell the template engine that achild template may override those portions of the template.
Child Template
- {% extends "layout.html" %}
- {% block title %}Index{% endblock %}
- {{ super() }}
- <style type="text/css">
- .important { color: #336699; }
- </style>
- {% block content %}
- <h1>Index</h1>
- <p class="important">
- Welcome on my awesome homepage.
The tag is the key here. It tells the template engine thatthis template “extends” another template. When the template system evaluatesthis template, first it locates the parent. The extends tag must be thefirst tag in the template. To render the contents of a block defined inthe parent template, use .