[Answered ]-How to chain {% includes %} in django templating

2👍

You need {{ block.super }}:

If you need to get the content of the block from the parent template,
the {{ block.super }} variable will do the trick. This is useful if
you want to add to the contents of a parent block instead of
completely overriding it.

Its burried in the template inheritance documentation.


Suppose you want to add extra stuff to the header block in auth.html. header is defined in index.html:

Your auth.html would look like:

{% extends "index.html" %}

{% block header %}
{{ block.super }} 
Your extra stuff, which will come after whatever was in the header block
{% endblock %}

Leave a comment