템플릿 forloop.counter 사용

2021. 1. 16. 16:43파이썬/Django

lists = ['a','b','c','d']

{% for list in lists %}
	{{ list }}{{ forloop.counter|add:1}}
{% endfor %}

결과값

a 2
b 3
c 4
d 5