コード例 #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})
コード例 #2
0
ファイル: views.py プロジェクト: ankur730/python_training
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})
コード例 #3
0
ファイル: views.py プロジェクト: kabaalkesh293/webapplication
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
コード例 #4
0
ファイル: views.py プロジェクト: ankur730/python_training
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})
コード例 #5
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})
コード例 #6
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, "index.html", {'form': form})
コード例 #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})
コード例 #8
0
ファイル: views.py プロジェクト: kabaalkesh293/webapplication
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)
コード例 #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')
コード例 #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')