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})
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'})
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' })
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})
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' })