How to output loop.counter in python jinja template?

后端 未结 5 523
-上瘾入骨i
-上瘾入骨i 2020-12-02 06:59

I want to be able to output the current loop iteration to my template.

According to the docs: http://wsgiarea.pocoo.org/jinja/docs/loops.html, there is a loop.count

5条回答
  •  攒了一身酷
    2020-12-02 07:23

    change this {% if loop.counter == 1 %} to {% if forloop.counter == 1 %} {#your code here#} {%endfor%}

    and this from {{ user }} {{loop.counter}} to {{ user }} {{forloop.counter}}

提交回复
热议问题