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, 'edit.html', {'employee': employee})
def emp(request): if request.method == "POST": form = EmployeeForm(request.POST) if form.is_valid(): try: form.save() return redirect('/show') except: pass else: form = EmployeeForm() return render(request, 'index.html', {'form': form})