Пример #1
0
def update_view(request, id):
    e = Employee.objects.get(id=id)
    if request.method == "POST":
        f = EmployeeForm(request.POST, instance=e)
        if f.is_valid():
            f.save(commit=True)
        return redirect("/home")
    return render(request, 'myApp/update.html', {'e': e})
Пример #2
0
def view1(request):
    f = EmployeeForm()
    d = {'f': f}
    if request.method == "POST":
        f = EmployeeForm(request.POST)
        if f.is_valid():
            f.save(commit=True)
    return render(request, 'myApp/input.html', d)
Пример #3
0
def update_view(request, id):
    e = Employee.objects.get(id=id)
    if request.method == 'POST':
        f = EmployeeForm(request.POST, instance=e)
        if f.is_valid():
            f.save(commit=True)
        return redirect("/")
    d = {'emp': e}
    return render(request, "myApp/update.html", d)
Пример #4
0
def insert_view(request):
    f = EmployeeForm()
    if request.method == "POST":
        f = EmployeeForm(request.POST)
        if f.is_valid():
            f.save(commit=True)
        return redirect('/')
    d = {'form': f}
    return render(request, 'myApp/insert.html', d)
Пример #5
0
 def insert_view(request):
     f=EmployeeForm()
     if request.method=="POST":
         f=EmployeeForm(request.POST)
         if f.is_valid():
             f.save(commit=True)
             return redirect("/")
             d={'form':f}
             return render(request,'myApp/insert.html',d)
             def delete_view(request,id):
                 e=Employee.objects.get(id=id)
                 e.delete()
                 return redirect('/')
                 def update_view(request,id):
                     e=Employee.objects.get(id=id)
                     if request.method=='POST':
                         F=EmployeeForm(request.POST,instance=e)
                         if f.is_valid():
                             f.save(commit=True)
                             return redirect("/")
                             d={'emp':e}
                             return render(request,'myApp/update.htmal',d)