员工匹配查询不存在

时间:2019-02-22 09:51:06

标签: database django-models django-forms

我在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__"

0 个答案:

没有答案