创建自定义表单时,我收到语法错误。错误在最后一行“self.fields ...”中。有谁知道正确的语法?
class UpdateStateWithOptionsForm(forms.ModelForm):
class Meta:
model = State
def __init__(self, *args, **kwargs):
super(UpdateStateWithOptionsForm, self).__init__(*args, **kwargs)
self.fields['relevantoption']forms.ModelMultipleChoiceField(queryset=Option.objects.all(),required=True, widget=forms.CheckboxSelectMultiple)