Пример #1
0
def editstudent(request,id):
    student = Student.objects.get(id=id)
    if request.method =='POST':
        modelform=StudentEditModelForm(request.POST, instance=student)
        if modelform.is_valid():
            modelform.save()
            return redirect('/')
    else:
        modelform= StudentEditModelForm(instance=student)
        return render(request,'edit.html',{'form':modelform})
Пример #2
0
def editstudent(request,id):
    request.session['id']=id
    student=Student.objects.get(id=id)
    if request.method=='POST':
        print("request.session['id']",request.session['id'])
        modelform=StudentEditModelForm(request.POST,instance=student)
        if modelform.is_valid():
            modelform.save()
            return redirect('/homee')

    else:
        modelform=StudentEditModelForm(instance=student)
        return render(request,'edit.html',{'form':modelform,'value':'Edit'})
Пример #3
0
def editstudent(request, id):
    student = Student.objects.get(id=id)
    if request.method == 'POST':
        modelform = StudentEditModelForm(request.POST, instance=student)
        if modelform.is_valid():
            modelform.save()
            messages.success(request, 'Update Successfully')
            return redirect('/')
    else:
        modelform = StudentEditModelForm(instance=student)
        return render(request, 'edit.html', {
            'form': modelform,
            'value': 'Edit'
        })
Пример #4
0
def edit(request, id):
    result = Student.objects.get(id=id)
    if request.method == 'POST':
        ModelForms = StudentEditModelForm(request.POST, instance=result)
        if ModelForms.is_valid():
            ModelForms.save()
            return redirect('/')

    else:
        ModelForm = StudentEditModelForm(instance=result)
        return render(request, 'edit.html', {'form': ModelForm})
Пример #5
0
def editstudent(request, id):
    request.session['id'] = 'Akshit'
    student = Student.objects.get(id=id)
    if request.method == "POST":
        modelform = StudentEditModelForm(request.POST, instance=student)
        if modelform.is_valid():
            modelform.save()
            messages.success(request, 'Edited Successfully')
            return redirect('/home/')
    else:
        modelform = StudentEditModelForm(instance=student)
        return render(request, 'edit.html', {
            'form': modelform,
            'value': 'Edit'
        })