【发布时间】:2018-07-31 16:55:57
【问题描述】:
我有一本字典,其中值在列表中
{
'Fees': ['88000', '88000'],
'ROll Number': ['I0', 'I1'],
'Mark': [10, 10]
}
所以我试图在表中插入这些数据,所以我的 Django 模板是
<table>
<thead>
<tr>
{% for k, v in loan_bank_info.items %}
<th>{{ k }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
<tr>
{% for k, value in loan_bank_info.items %}
{% for v in value %}
<td>{{ v }}</td>
{% endfor %}
{% endfor %}
</tr>
</tbody>
</table>
但表中的值打印如下,
Fees ROll Number Mark
88000 88000 I0 I1 10 10
但我想要的是-
Fees ROll Number Mark
88000 I0 10
88000 I1 10
如何在 Django 模板中迭代列表值
【问题讨论】:
-
我认为您需要将
<tr>和</tr>标签放在外部for循环内
标签: python django dictionary django-templates