【发布时间】:2010-11-17 05:46:01
【问题描述】:
大师们, 我在这个问题上搜索了很多次,但我几乎找不到任何有用的信息。
所以假设我们有一个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 %}
现在我们有第四个模板root.html
<html>
<body>
{% include 'a.html' %}
{% include 'b.html' %}
{% include 'base.html' %}
</body>
</html>
所以当我渲染 root.html 时,我希望得到类似的东西:
这是A!这是B!这是基地!
但奇怪的是我得到的总是:
这是A!这是A!这是A!
为什么会发生这种情况?
【问题讨论】:
标签: django templates include extends