템플릿 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
'파이썬 > Django' 카테고리의 다른 글
In order to allow non-dict objects to be serialized set the safe parameter to False. (0) | 2021.01.16 |
---|---|
Django custom template tag filter 추가 (0) | 2021.01.16 |
'with' expected at least one variable assignment (0) | 2021.01.16 |
Could not parse the remainder: '['a','b','c','d']' from '['a','b','c','d']' (0) | 2021.01.16 |
'Manager' object is not callable (0) | 2021.01.16 |