大家好,
我在谷歌上搜索了很多次这个问题,但几乎找不到有用的信息。
假设我们有一个名为
在此之下有两个子模板,
a.html:
现在我们有第四个模板,名为
当我渲染root.html时,我希望得到以下内容:
假设我们有一个名为
base.html
的模板:{% block test %}This is the base!{% endblock %}
在此之下有两个子模板,
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 %}
现在我们有第四个模板,名为
root.html
。<html>
<body>
{% include 'a.html' %}
{% include 'b.html' %}
{% include 'base.html' %}
</body>
</html>
当我渲染root.html时,我希望得到以下内容:
但奇怪的是,我总是得到以下内容:这是A!这是B!这是Base!
这是为什么呢?在IT技术方面,您可能需要检查代码逻辑和变量赋值。这是A!这是A!这是A!