我有一个上下文变量:
"images": [
{
"date": "2015-06-02T11:51:53Z",
"image": "auction/Screenshot_from_2015-05-18_235741.png",
"auction_id": 1,
"id": 1
},
{
"date": "2015-06-23T09:38:45Z",
"image": "auction/Screenshot_from_2015-06-22_203407.png",
"auction_id": 1,
"id": 2
},
.....
],
我想以下列方式遍历这个字典列表
{% for image in images %}
<a class="thumb-item-link" data-slide-index="{{over here should be the index of the current iteration}}" href=""><img src="/media/{{image.image}}" alt="img"/></a>
{% endfor %}
例如: -
<a class="thumb-item-link" data-slide-index="0" href=""><img src="/media/auction/Screenshot_from_2015-05-18_235741.png" alt="img"/></a>
<a class="thumb-item-link" data-slide-index="1" href=""><img src="/media/auction/Screenshot_from_2015-06-22_203407.png" alt="img"/></a>
<a class="thumb-item-link" data-slide-index="2" href=""><img src="/media/auction/Screenshot_from_2015-06-22_203488.png" alt="img"/></a>
此处data-slide-index
正在根据当前迭代更改其值。我怎样才能做到这一点?