添加,不覆盖模板块

时间:2013-05-09 19:45:34

标签: python django

我在一个简单的博客引擎的Django模板中有一段代码:

    {% block mainLeft %}
    <section class="container" id="main">
        <section class="offset1 span8" id="mainLeft">
        </section>
    {% endblock %}

#mainleft部分中为不同模板添加内容的正确方法是什么?例如,如果我想根据从上下文传入的信息在section标签中动态生成div。

1 个答案:

答案 0 :(得分:6)

在块中使用{{ block.super }}See the docs.

相关问题