我在应用程序中使用模型表单,
模型.py
class Report(models.Model):
manual_date_time = models.DateTimeField('Another time', null=True, blank=True)
modelform.py 是
class ReportForm(forms.ModelForm):
class Meta:
model = Report
fields = ['incident_description','manual_date_time', 'location_description',
'incident_followup', 'incident_followup_name_1', 'incident_followup_email_1',
'incident_followup_name_2', 'incident_followup_email_2', 'phone_call_log',
'notes_other','notes_firstaid','notes_risk']
class ReportPersonForm(forms.ModelForm):
class Meta:
model = ReportPerson
fields = ['name','first_aid','sick_bay','ambulance']
模板是
在我的模板中,我使用下面的代码来呈现字段,但字段区域未显示在模板中。
{{ form.manual_date_time }}
视图.py
def when(request):
return render(request, 'incident/when.html',
{
'newreport_menu': True,
})
我可以知道我做错了什么吗?