We've taken the press release section of our project and defined a base template that acts as a parent template, and two child templates that can extend the base template. In a real-world project, we'd take this one step further and create another parent template for use site-wide. With this setup, we'd have a site-wide base template, a section-wide base template, and child templates that inherit from the section-wide base.
Here's an illustration of how that would look:
Let's add this three-level setup to our project. We'll have to make three changes: add a site base template, change the section base template to extend the site base, and move site-wide code from the section base to the site base.
In the mycompany/templates
directory, add a new file called site_base.html
, adding the following lines:
<html> <head> <title>{% block title %}{% endblock title %}<title> <style type="text/css"> body { text-align: center; }...