我有以下情况:
2 意见:
视图1:
return render(request, 'template1.html', {'var1': 'value1'} )
视图2:
return render(request, 'template2.html', {'var2': 'value2' } )
2个模板:
模板1.html
{% block foo %}
{{ var1 }}
{% endblock %}
模板2.html
{% extends template1.html %}
{% block foo %}
{{ block.super }}
{{ var2 }}
{% endblock %}
Template1.html 的所需输出:
value1
Template1.html 的实际输出:
value1
Template2.html 的所需输出:
value1 value2
实际输出:
value2
为什么调用 {{block.super}} 时没有输出 'var1' 的值?
我在我的 settings.py 中定义了“django.core.context_processors.request”。我错过了什么?