在 Django 中,我有一个字典,其中包含字典,例如:
d['dict1'] = [('1', 'some information'), ('2', 'some information')]
d['dict2'] = [('1', 'some more information'), ('2', 'some more information')]
我需要循环遍历它,但是每次循环遍历它只获取与loop.counter对应的dict1和dict2的值,所以例如
first time through it would output
1 3
and then
2 4
and so on and so forth
我试着做:
{% for item1, item2 in d.items %}
{{ item1.forloop.counter.value1 }}
{{ item2.forloop.counter.value1 }}
{% endfor %}
它什么也没有产生。
编辑:我更新了字典的实际样子