我在Django比较新鲜。我正在尝试应用程序,因为我正在尝试更新员工记录。但是遇到这个错误,我在做什么错了?
views.py
def update(request, id):
employee = Employee.objects.get(id=id)
form = EmployeeForm(request.POST, instance=employee)
if form.is_valid():
form.save()
return redirect('/show')
return render(request,'myapp/edit.html',{'employee':employee})
forms.py
from django import forms
from myapp.models import Employee
class EmployeeForm(forms.ModelForm):
class Meta:
model = Employee
fields = "__all__"