当我扩展base.html / for django时,是否可以排除base.html中包含的footer.html

时间:2016-03-02 16:27:16

标签: html django

在我的base.html中,我有{% include 'footer.html' %},我将base.html扩展到我的每个页面。但对于某些页面,我不想让页脚在那里。是否可以使用某个块关键字排除该页脚?

1 个答案:

答案 0 :(得分:8)

您可以在block中使用base.html

# base.html
...
{% block footer %}
    {% include 'footer.html' %}
{% endblock %}

然后在你不想要页脚的模板中,执行以下操作:

# Some template
{% block footer %}
{% endblock %}