【发布时间】:2011-09-24 08:51:15
【问题描述】:
我有这个代码
{% for account in object_list %}
<tr>
{% for field, value in book.get_fields %}
<th>{{ field.verbose_name }}</th>
{% endfor %}
</tr>
{{ break }}
{% endfor %}
我想在第一次迭代后打破 for 循环。休息不工作
【问题讨论】:
-
如果要在第一次迭代后停止,为什么要使用循环?使用
{% with account=object_list|first %} ... {% endwith %}
标签: django for-loop django-templates