def reporttable(request):
report_table = RepairReport.objects.all()
pre_report_entering_form = ReportEnteringForm()
if request.method == 'POST':
pre_report_entering_form = ReportEnteringForm( request.POST )
if pre_report_entering_form.is_valid():
report_entering_form = pre_report_entering_form.save( commit = False )
report_entering_form.save()
return render_to_response('reporttable.html', RequestContext(request,
locals(),
)
)
else:
return HttpResponse('hello world')
else:
return render_to_response('reporttable.html',RequestContext(request,
{'report_entering_form': pre_report_entering_form, 'report_table':report_table}
)
)
以上是我的视图函数。我现在在表单上填写数据,点击保存按钮后,没有成功的把数据保存到数据库中,不知道为什么。请问应该怎么做?