【发布时间】:2011-07-29 20:21:06
【问题描述】:
您好,我似乎在 Django 中遇到了一些计数问题。我有一个仅显示其最新状态的项目列表。所有这些状态为“已销毁”的物品都已被移除。这打印得很好。
status_items = models.StorageItem.objects.filter(client=client_id, itemstatushistory__isnull=False).distinct()
{% for item in status_items %}
{{item.itemstatushistory_set.latest|cut:"Destroyed"}}
{% endfor %}
但由于某种原因我数不清。
status_items = models.StorageItem.objects.filter(client=client_id, itemstatushistory__isnull=False).distinct().count()
TypeError while rendering: 'int' object is not iterable
【问题讨论】:
-
顺便说一句,如果可能的话,你应该接受更多的答案。
标签: python django templates django-templates