【问题标题】:Adding to, Not Overriding a Template Block添加到,而不是覆盖模板块
【发布时间】:2013-05-04 09:45:14
【问题描述】:

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

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

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

【问题讨论】:

    标签: python django


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2023-03-22
      • 2018-12-13
      • 2021-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多