3
大师, 我在这个问题上搜索了很多次,但我几乎找不到任何有用的信息。怪异的模板包括并扩展了Django行为
所以假设我们有一个base.html
模板:根据该
{% block test %}This is the base!{% endblock %}
与2子模板,a.html
和b.html
a.html:
{% extends "base.html" %}
{% block test %}This is the A!{% endblock %}
b.html
{% extends "base.html" %}
{% block test %}This is the B!{% endblock %}
现在我们有4模板root.html
<html>
<body>
{% include 'a.html' %}
{% include 'b.html' %}
{% include 'base.html' %}
</body>
</html>
所以,当我渲染root.html,我期望得到某物像:
这是A!这是B!这是基地!
但奇怪的是我得到的始终是:
这是A!这是A!这是A!
为什么会发生这种情况?