Answer the question
In order to leave comments, you need to log in
How to make a loop counter in a django template?
Django. I output a cycle of articles in the template through for.
How to make a counter. Type i. That is, in the for block, there was a variable i inside.
That is, I need to change the class name of the div after 3 cycles.
Answer the question
In order to leave comments, you need to log in
{{ forloop.counter0 }} - starts from zero
{{ forloop.counter }} - starts from one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question