【发布时间】:2012-02-20 12:04:56
【问题描述】:
我有以下几点:
base.html
<html>
{% include 'header.html' %}
<div>
{% block content %}Default Content{% endblock %}
</div>
</html>
header.html
<header>
{% block logo %}Logo 1{% endblock %}
</header>
homepage.html
{% extend 'base.html' %}
{% block logo %}Logo 2{% endblock %}
{% block content %}Yap Yap Yap{% endblock %}
基本上,这是行不通的。当我渲染 homepage.html 时,我得到:
<html>
<header>Logo 1</header>
<div>Yap Yap Yap</div>
</html>
但是如果我将header.html 中的代码移动到base.html(即完全摆脱include),它就可以了。谁能解释为什么会这样?
我感觉这与 included 模板在其父级渲染后渲染有关?
【问题讨论】: