if I want to set up a choices field values in a view,
I am doing
## forms.py
class MyFormClass(forms.Form):
users = form.ChoicesField()
## views.py
my_choices = [(c.id, c.username) for c in users]
my_form = MyFormClass()
form.fields['users'].choices
# pass it back to the template
Is this a good way to do this?
The form displays my choices in the correct way, seemingly.
I see <option value="3">jim</option> on the form control, but when I submit the form I get the following validation error:
Select a valid choice. 3 is not one of the available choices.
Any suggestions on debugging this?
Thanks!