KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a select field in the form and now I need to iterate over options in this field. {{ form.myselect }} gives me this: <select name="myselect" id="id_myselect"> <option value="" selected="selected">---------</option> <option value="2">Item 1</option> <option value="3">Item 2</option> ... </select> Now I need to add some attributes to the options and because of that what I need is: <select name="myselect" id="id_myselect"> {% for x in form.myselect %} <option value="{{ x.id }}">{{ x.name }}</option> {% endfor %} </select> but there is an error: Caught TypeError while rendering: 'BoundField' object is not iterable I tried form.myselect.all , form.myselect.option_set but it gives nothing
Tags (comma-separated)
Save Edits
Cancel