Simon Griffee

Override Django Template Blocks ➶

2 April 2014

base.html

<html>
    <body>
        {% block header %}{% include "header.html" %}{% endblock %}
    </body>
</html>

header.html

<div id="header">
    <img src="#">
    {% include nav_tmpl|default:"navigation.html" %}
</div>

special_page.html (uses other navigation)

{% extends "base.html" %}
{% block header %}
    {% include "header.html" with nav_tmpl="special_nav.html" %}
    # you might also want to wrap the include in an 'if' tag if you don't want anything
    # included here per default 
{% endblock %}

What

Share