Django counter in loop to index list

前端 未结 5 431
鱼传尺愫
鱼传尺愫 2020-12-29 12:33

I\'m passing two lists to a template. Normally if I was iterating over a list I would do something like this

{% for i in list %}

but I hav

5条回答
  •  孤独总比滥情好
    2020-12-29 13:16

    I ended up having to do this:

    {% for x in x_list %}
      {% for y in y_list %}
        {% if forloop.counter == forloop.parentloop.counter %}
           Do Something
        {% endif %}
      {% endfor %}
    {% endfor %}
    

提交回复
热议问题