我试图在表单中添加一个初始值为'-'的字段,以便除非对其进行更改,否则将其传递给表单。
我在表单集中使用此表单。
forms.py
class ClinicallyReportedVariantForm(forms.ModelForm):
report_germline = forms.CharField(
label='Germline:',
initial='-',
)
class Meta:
model = ClinicallyReportedVariant
fields = (
'id',
'report',
'report_annotation',
'report_evidence',
'report_germline',
)
观看次数:
formset = modelformset_factory(
ClinicallyReportedVariant,
form=self.crvform,
formset=BaseCRVFormSet,
extra=0,
)
self.formset = formset(queryset=crv_obj)
for form in self.formset:
print(form)
此字段的输出为:
<label for="id_form-0-report_germline">
Germline:</label>
</th><td><input type="text"
name="form-0-report_germline"
id="id_form-0-report_germline"
/>
为什么value ='-'不在字段中?