2013-10-22 86 views

回答

0

可以這樣設置初始值:

class MyForm(forms.Form): 
    choices = forms.MultipleChoiceField(choices=(
      ('choice_1', 'Choice 1'), ('choice_2', 'Choice 2')) 

    def __init__(self, *args, **kwargs): 
     super(MyForm, self).__init__(*args, **kwargs) 
     self.fields['choicefield_name'].initial = ['choice_1', 'choice_2'] 
相關問題