大师,我在这个问题上搜索了很多次,但我几乎找不到任何有用的信息。
所以假设我们有一个base.html
模板:
{% block test %}This is the base!{% endblock %}
以及其下的 2 个子模板,a.html
以及b.html
一个.html:
{% extends "base.html" %}
{% block test %}This is the A!{% endblock %}
b.html
{% extends "base.html" %}
{% block test %}This is the B!{% endblock %}
现在我们有第四个模板root.html
<html>
<body>
{% include 'a.html' %}
{% include 'b.html' %}
{% include 'base.html' %}
</body>
</html>
因此,当我渲染 root.html 时,我希望得到类似:
这是A!这是B!这是基地!
但奇怪的是,我得到的总是:
这是A!这是A!这是A!
为什么会发生这种情况?