今天遇到这个问题,和上面的一样。
比如layout/main.html 中这样写着,
include 'layout/header.html',
...
include 'layout/footer.html'
像layout/main.html 中有这样一个block
{% block other_css %}
... css ...
{% endblock %}
其它的页面这样:
{% extends "layout/main.html" %}
{% block other_css %}
... new css ...
{% endblock %}
但是这样试了不行. new css显示不了。唯一可行的办法就是不要将需要block的放进include 这样的子模板中。
所以索性,我直接在layout/main.html 中把header.html的内容放进main.html里,需要被修改的部分再抽成block
最终layout/main.html长这样
...
{% block other_css %}
... css ...
{% endblock %}
include 'layout/nav.html',
...
include 'layout/footer.html'