I have a template that includes another template. This included template has block tags in it.
Example:
base.html
BASE
{% block title %}Base Title{% endblock %}
{% block content %}{% endblock %}
template1.html
{% extends 'base.html' %}
{% block title %}Extended Title{% endblock %}
{% block content %}
Extended content
{% include 'include.html' %}
{% endblock %}
include.html
{% block title %}Include Title{% endblock %}
{% block another_content %}Include Content{% endblock %}
What I'm expecting is if I render template.html I should get, which I do under 1.1.1
BASE
Extended Title
Extended content
Include Title
Include Content
But I actually get this when I switched to 1.2.1 and 1.2.3:
BASE
Extended Title
Extended Content
Extended Title
Include Content
As you can see, the title block in include.html gets replaced with template1.html's title block. This replacement only happens if the block names are the same, so if I change the title block in include.html, this doesnt occur. It seems to me that it's including and extending at the same time? Anyone know if this is expected/I'm doing something wrong?
If you're not using
extends
ininclude.html
then this behaviour is normal - I suppose that there was a bug in 1.1.1.Excerpt from official documentation:
Read whole thing here: Template Inheritance
If that's what you want, then the include.html should not contain any blocks at all, ie just: