我正在尝试将变量传递给子模板:{% block footer %} {% include '_footer.html' with var="foo" %}{% endblock footer %}但我收到 django 错误:Exception Type: TemplateSyntaxError at /Exception Value: expected token 'end of statement block', got 'with'我究竟做错了什么?
1 回答

隔江千里
TA贡献1906条经验 获得超10个赞
您必须先声明变量,然后包含子模板
{% block footer %}
{% with var="foo" %}
{% include "_footer.html" %}
{% endwith %}
{% endblock %}
添加回答
举报
0/150
提交
取消