Form is invalid

Submitted 1 year, 11 months ago
Ticket #18
Views 125
Language Django
Priority High
Status Closed

i am trying to update a record from mysql database. Following is my update func.

def update(request,id):
    form=LoginForm(request.POST, instance=user)
    if form.is_valid():
        print("Form is valid.")
        return redirect("/show")
        print("Form is In-valid.")
    return render(request,"edit.html",{"qs":user})

in the terminal it is saying that form is In-valid as i printed in the command of else part so this means the form that i created above is not valid dont know what to do kindly help.

Submitted on Jun 08, 20
add a comment

1 Answer


Submitted 1 year, 11 months ago

dont pass the user instance to the form creation, form=LoginForm(request.POST or None). Try this

- scott 1 year, 11 months ago

By doing this wont be the values of the fields that needed to be save would be lost ?

- moazamrana22 1 year, 11 months ago

after form valid add the user . It should work. like form = form(commit=false form.user = user try something like this

- arun 1 year, 11 months ago

As we are not getting any update on this ticket, as you raised as HIGH priority. Hopefully you have resolved the issue. So we go ahead and close the ticket. In case if doesnt work , then submit the new one.

- arun 1 year, 11 months ago

Wanna Post Ad?
Reach a large group of audience by posting an ad about your business here. For more details
Drop us a Message