我正在迭代一个formset来处理每个表单,但无论出于何种原因,formset中的表单都有一个空的cleaning_data。
这是我的视图代码(片段):
for dform in directors_formset:
dform.is_valid() # has no effect on cleaned_data, returns true
ddata = dform.cleaned_data
email = ddata['officer_email']
Directors_formset已通过验证。 POST请求包含director_formset表单中的字段。但是,ddata == {}。为什么?
编辑:这是表单定义:
class OfficerForm(forms.Form):
is_secretary = forms.ChoiceField(choices=(('DIR', 'a director'), ('SEC', 'a secretary')),
label='This officer will be:',
initial='DIR',
widget=forms.RadioSelect(renderer=SaneRadioField))
is_corporate = forms.ChoiceField(initial='IND',
label='This officer is:',
choices=(("IND", "an individual"),
("EEA", "incorporated in the EEA (including the UK)"),
("FOR", "incorporated outside the EEA")),
widget=forms.RadioSelect(renderer=SaneRadioField))
given_name = forms.CharField()
surname = forms.CharField()
previous_names = forms.CharField()
residential_address = forms.CharField(widget=forms.Textarea)
company_name = forms.CharField()
service_address = forms.CharField(widget=forms.Textarea)
officer_email = forms.CharField()
dob = forms.DateField(label='Date of birth:')
business_occupation = forms.CharField()
nationality = forms.CharField()
country_of_residence = forms.CharField()
where_registered = forms.CharField()
registration_number = forms.CharField()
legal_form = forms.CharField()
governing_law = forms.CharField()