【发布时间】:2015-07-06 13:43:38
【问题描述】:
我是 django&python 的新手。 使用 python 3.4.2 和 django 1.8。 尝试显示产品列表并遇到错误:
"异常类型:TemplateSyntaxError
异常值:无效块标签:'endfor'
异常位置:myvirtualenv/lib/python3.4/site-packages/django/template/base.py invalid_block_tag,第 395 行“
不知道出了什么问题。在 stackoverflow 上发现了一些相关的问题,但它们没有帮助。
请给我一个提示。提前致谢。
观看次数:
from django.shortcuts import render
from .models import Product
def list_items(request):
products = Product.objects.all()
return render(request, 'catalog/list_item.html', {'products': products})
list_item.html:
<html>
<head>
{% block title %}some title{% endblock %}
</head>
<body>
{% for product in products %)
{{ product }}
{% endfor %}
</body>
</html>
P.S 如果没有内容,{% block title %} 会毫无错误地呈现。
【问题讨论】:
标签: python django templatetags templatetag