Thursday, November 30, 2017

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


- 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"
        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
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment