How to complement the block of parent template?

Viewed 41

I have first.html:

    {% block title %}
        hi there
    {% endblock %}

    {% block content %}
        blah-blah
    {% endblock %}

    {% block footer %}
        bye
    {% endblock %}

and second.html. How can I incude all first.html page to second.html and complement content block like this:

hi there
blah-blah
this text is from second.html
bye

I've tryed

{% extends "first.html" %}
this text is from second.html

(just nothing added) and

{% extends "first.html" %}
{% block content %}
    this text is from second.html
{% endblock %}

(block content is overrided).

1 Answers

You can make use of {{ block.super }} [Django-doc] here when you want to render the original content as well. For example:

{% extends 'first.html' %}
{% block content %}
    {{ block.super }}
    this text is from second.html
{% endblock %}

Related