Thursday, November 30, 2017

Re: Why does Django say my login form is invalid? How can I find out why Django thinks it is?

Tom,

- You shouldn't use Model=User (or the Meta) as it was a ModelForm, it is just a regular Form
- AuthenticationForm takes request as its first parameter:

def login_register(request, template="templates/login_register.html"):
    if request.method == "POST":
        login_form = AuthenticationForm(request, data=request.POST)
        if login_form.is_valid():
            print("Login form valid")
            # return redirect(home_slug())
        # else:
        #  print "Login invalid"
    else:
        login_form = AuthenticationForm()
    return render(request, template, {"login_form": login_form})


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BFDnh%2B1i4eRye6qr%3DF2zWz2Nnf4mAZ1%3DnY357m01HSyeFL0UA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment