Использование forloop.counter для доступа к элементам массива в шаблонах django
I have a form element form.category and an array categories being passed to a django template like this
<ul id="cat_options">
{% for x in form.category %}
<li class="results" id="results_{{forloop.counter}}" name=''>
{{x}}
</li>
{% endfor %}
</ul>
here the length of form.category is same as categories
теперь я хочу дать атрибут name каждому элементу li, как
<li class="results" id="results_{{forloop.counter}}" name={{categories.forloop.counter}}>.
But this doesn't seem to work. I have also tried name="{{categories}}-{{forloop.counter}}".
Спасибо