-
Book Overview & Buying
-
Table Of Contents
Django 1.0 Template Development
By :
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."
In the diagram we say that page.html extends base.html. To accomplish this, we're going to make a hole in base.html that will...
Change the font size
Change margin width
Change background colour