With template extension, you create labeled "blocks" in your parent templates that get filled with content from child templates. Let's illustrate this with a diagram:
Notice that the arrow is pointing from the child template to the parent template. In Django templates, you start from a child template and work up into parent templates. In this example, the view would load and parse page.html
, and the rendered output from page.html
would go into base.html
via logic in the template file.
Looking at the diagram, base.html
(the parent template) has a "hole" where the output of page.html
(the child template) goes. The hole in the parent is labeled with a block
tag so that it can be identified by the child. The label tells the template engine, "This area can be replaced by content in a child template if you have it."