我正在尝试验证表单,但以错误结尾,我试图以一种表单获取两个模型。
views.py:
def ipd (request,patient_id):
patient = Patient.objects.get(pk=patient_id)
if request.method=="POST":
data = dict(request.POST)
data['patient']=Patient.Patient_id
formtwo = IpdForm(request.POST)
if formtwo.is_valid():
if formtwo.save():
return render('ipd_list', messages.success(request,
'Patient is successfully updated.', 'alert-success'))
else:
return render('ipd_list', messages.error(request, 'Data is
not saved', 'alert-danger'))
else:
return formtwo.errors
else:
formtwo = IpdForm()
return render(request, 'newipd.html', {'form2':formtwo
,'form':patient})