0
我MultipleChoiceFieldfield获取元素迭代thgrough多种选择领域的Django的指数为环
OPTIONS = (
("AUT", "Austria"),
("DEU", "Germany"),
("NLD", "Neitherlands"),
)
countries = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple(attrs={"name": "select_0","class": "fff"}),
choices=OPTIONS)
我建立我自己的HTML结构这一领域,这被简化代码:
{% for value, text in simple_search_form.countries.field.choices %}
{{value}}
{{text}}
{% endfor %}
怎么办我在这里得到每个元素的索引? 我需要有
{{value}}
{text}}
{{index}}