0
在Django中,我有一本字典,其中包含词典,例如:遍历Django的字典
d['dict1'] = [('1', 'some information'), ('2', 'some information')]
d['dict2'] = [('1', 'some more information'), ('2', 'some more information')]
,我需要遍历它,但每次它遍历只抢到dict1的价值和dict2与loop.counter对应,所以例如
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 %}
它什么都不产生。
编辑:我更新了一下字典实际上看起来像
还好,但我的问题是,我该怎么做,在我看来,它使用一个循环来获取所有necesary对象,并把它放在字典(ies) – flaiks
请提供您的视图中的代码。 –