Edit record is not saving changes in frontend

2021-03-22 Thread Wale Olajumoke
I am creating a CRUD application. The create, read and delete function are working but edit record is showing the instance in the form* but it is not saving changes.* *Here is my code.* *===* *views.py* def edit(request, id): student = Student.objects.get(id=id) form = StudentForm

Re: Record is not saving

2010-01-30 Thread Praveen
Thanks Actually earlier i was passing instance of Phone phoneform = PhoneForm(request.POST,instance=Phone.objects.get (user=request.user)) but at very first time there was no record in Phone table that is what i was getting the sql query is not matching so i tried with try: userob =

Re: Record is not saving

2010-01-30 Thread cootetom
You are created a PhoneForm but passing it an instance of User. You need to pass the form an instance of the model it works on. - Tom On Jan 30, 3:45 pm, Praveen wrote: > Hi > > here is my views > def phone_register(request, success_url=None,form_class = PhoneForm, >                 template

Record is not saving

2010-01-30 Thread Praveen
Hi here is my views def phone_register(request, success_url=None,form_class = PhoneForm, template_name="phone/phonereg_form.html", extra_context=None): userobj = User.objects.get(pk=request.user.id) if request.method == 'POST': phoneform = form_class(request.POST, i