cannot set initial value for forms.ChoiceField in django

Viewed 5634

everyone

I want to set initial value for ChoiceField while that value isn't in choices of ChoiceField

following is the ArticleForm definition:

def ArticleForm(forms.Form):
  choice = forms.ChoiceField(choices=[['a':'a'],['b':'b']])

then I instantiated the form by passing the initial argument:

form = ArticleForm(initial={'choice':'Portrush'})

notice that the initial value('Portrush') isn't one of choices defined in ChoiceField('a' and 'b')

How could I set initial value? Any suggestion is appreciated.

1 Answers
Related