Reputation: 5802
I have a form:
class MatchForm(forms.Form):
base_field = forms.CharField(widget=forms.Select)
def __init__(self ,*args, **kwargs):
BASE_FIELDS = (
('job','JOB'),
('car','CAR'),
)
super(MatchForm,self).__init__(*args, **kwargs)
self.fields['base_field'].choices = BASE_FIELDS
with this class that I have written, there is no any option in select. How can I insert BASE_FIELDS
in base_field
field.
Thanks in advance
Upvotes: 0
Views: 90
Reputation: 2445
BASE_FIELDS = (
('job','JOB'),
('car','CAR'),
)
class MatchForm(forms.Form):
base_field = forms.ChoiceField(choices=BASE_FIELDS)
Upvotes: 3