我的基本模板是为什么django在扩展后生成空字符串?
<!DOCTYPE html>
<html lang="en">
<head>
<title>{% block title %}My amazing site{% endblock %}</title>
</head>
<body>
<div id="sidebar">
{% block sidebar %}
<ul>
<li><a href="/">Home</a></li>
<li><a href="/blog/">Blog</a></li>
</ul>
{% endblock %}
</div>
<div id="content">
{% block content %}{% endblock %}
</div>
</body>
</html>
索引页:
{% extends "base.html" %}
{% block title %}My amazing blog{% endblock %}
{% block content %}
{% for entry in blog_entries %}
<h2>{{ entry.title }}</h2>
<p>{{ entry.body }}</p>
{% endfor %}
{% endblock %}
什么是错的,为什么它是产生这些引号内的怪空的文本? 它影响我的布局。你有什么想法?谢谢。你的标题标签插入身体标记
我注意到,但模板代码似乎是正确的。 – 2012-02-25 18:40:52
您确定模板index.html扩展了base.html吗? – greg 2012-02-26 12:43:48
是的,只有两个文件,并从这两个文件合并得到的html。 – 2012-02-26 19:22:45