Exemple #1
0
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 update(request, id):
    employee = Employee.objects.get(id=id)
    form = EmployeeForm(request.POST, instance=employee)
    if form.is_valid():
        form.save()
        return redirect(show)
    else:
        pass
Exemple #3
0
def update(request, id):
    employee = Employee.objects.get(id=id)
    if request.method == 'POST':
        form = EmployeeForm(request.POST, instance=employee)
        if form.is_valid():
            form.save()
            return redirect('/')
    return render(request, 'crudapplication/update.html',
                  {'employee': employee})
Exemple #4
0
def update(request, id):
    employees = Employee.objects.get(id=id)
    form = EmployeeForm(request.POST, instance = employees)
    if form.is_valid():
            try:
                form.save()
                return redirect("/getAll")
            except:
                pass
    return render(request, "edit.html", {'employees':employees})
Exemple #5
0
def create_view(request):
    form = EmployeeForm()
    if request.method == 'POST':
        form = EmployeeForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect('/')
    return render(request, 'crudapplication/create.html', {'form': form})
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})
Exemple #7
0
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, 'employee_form.html', {'form': form})
def create(request):
    if request.method == 'POST':
        form = EmployeeForm(request.POST)
        if form.is_valid():
            try:
                form.save()
                return redirect(show)
            except:
                pass
    else:
        form = EmployeeForm()
    context = {'form': form}
    return render(request, 'create.html', context)
Exemple #9
0
def emp(request):
    if request.method == "POST":
        form = EmployeeForm(request.POST)
        if form.is_valid():
            try:
                form.save()
                return redirect()

            except:
                pass
    else:
        form = EmployeeForm()
    return render(request, "", 'Form')
Exemple #10
0
def edit(request, id=0):
    if request.method == "GET":  # Ye info lekr ayga
        if id == 0:  # Yaha ye new bande ko form dakhayega 0 means new user
            form = EmployeeForm()
        else:  # yaha jo app link mai id dogy user us ki info dakhyga
            employee = Employee.objects.get(pk=id)
            form = EmployeeForm(instance=employee)
        return render(request, "employee_form.html", {'form': form})
    else:
        if id == 0:  # Yaha ye new bande ko form dakhayega 0 means new user
            form = EmployeeForm(request.POST)
        else:  # yaha jo app link mai id dogy user us ki info dakhyga or changes karre k bad DB mai b POST karega
            employee = Employee.objects.get(pk=id)
            form = EmployeeForm(request.POST, instance=employee)
        if form.is_valid(
        ):  # Form agar sahi fill kara hoga phr DB mai save kar dega
            form.save()
        return redirect('/show')