3

大师,我在这个问题上搜索了很多次,但我几乎找不到任何有用的信息。

所以假设我们有一个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!

为什么会发生这种情况?

4

1 回答 1

2

好的,我想我找到了根本原因:djang debug_toolbars 插件。一旦我在 settings.py 中禁用它,那么一切正常......

这很奇怪,但我想我会在插件的问题跟踪列表中发布问题。

希望这可以帮助遇到同样问题的人

[编辑] 这个错误看起来像是在最新的 0.8.4 修订版中得到修复,它在 0.8.3 时代让我非常烦恼。

于 2010-11-17T06:06:26.720 回答