I have a simple form that I'm using to update data.
All data are correctly loaded, however the current value from my choice field (pull down menu) is the only one not initially selected with current value.
My Django Form:
class MyForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
choices = (
('', 'Select'),
('1', 'Option 1'),
('2', 'Option 2'),
)
self.fields['myfield'] = forms.ChoiceField(
required=True,
error_messages = {'required': 'Field is Required!'},
label='My Label',
choices=choices,)
...
Aucun commentaire:
Enregistrer un commentaire