我有两个文件,location = 'cat'
# Notice the location with braces, and the one without.
html = '<input value="{location}" name="location" type="text" />'
print(html.format(location = location))
# outputs <input value="cat" name="location" type="text" />
# the location with braces is replaced.
和base.html
。主页扩展了基础,并添加到块homepage.html
。 Base应该在正文中的范围内渲染块extra
,但不会。
base.html文件:
extra
homepage.html:
{% load sekizai_tags %}
<!doctype html>
<html>
<head>
<title>Title</title>
</head>
<body>
<span style="color: red;">{% render_block "extra" %}</span>
{% block 'content' %}
{% endblock %}
</body>
</html>
输出:
我错过了什么非常简单的事情?
答案 0 :(得分:0)
啊哈,我错过了模板中的上下文预处理器。
'sekizai.context_processors.sekizai',