我的视图django中出现错误(| as_crispy_field传递了无效或不存在的字段),请在这里告诉我错误。我不明白。该模板对我来说正常工作,但是在保存数据时对我不起作用。这是我的代码:
views.py
my_form = AlumnoForm()
my_form2 = ApoderadoForm()
if request.method == "POST":
my_form = AlumnoForm(request.POST) and ApoderadoForm(request.POST)
if my_form.is_valid() and my_form2.is_valid():
print(my_form.cleaned_data)
print(my_form2.cleaned_data)
Alumno.objects.create(**my_form.cleaned_data)
Apoderado.objects.create(**my_form2.cleaned_data)
return redirect('list_student')
else:
print(my_form.errors)
print(my_form2.errors)
extra_context = {
'form' : my_form,
'form2': my_form2
}
return render(request, "create_student.html", extra_context) ```