【发布时间】:2020-11-27 18:21:33
【问题描述】:
在我的 django 模板中,我想按如下数量复制一行:
类似于重复材料请求 67 14 次,34 15 次等等
为此,我在如下列表中检索了数量:
d_docket = AllotmentDocket.objects.filter(parent_company = client_pk.pk, transaction_date__range =[start, end]).order_by('-transaction_date')
quan = list(d_docket.values_list('product1_quantity', flat=True))
给出:
[14, 15, 15, 15, 15, 20, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 13, 6, 15, 15, 10、15、15、15、7、8]
但是如何在 django 模板中遍历quan 的每个元素的范围?
当前模板:
{% for i in query %}
<tr>
<td class="align-middle">{{ i.sales_order.owner }}</td>
<td class="align-middle">{{ i.sales_order.pk }}</td>
<td class="align-middle">{{ i.sales_order.flow }}</td>
<td class="align-middle">{{ i.sales_order.kit }}</td>
</tr>
{% endfor %}
【问题讨论】:
标签: python html django django-templates