django form is valid() fails

前端 未结 2 448
有刺的猬
有刺的猬 2021-01-15 06:04

I am trying to create a registration form using django, when I submit my form the is valid() function fails and I am not sure why. I have my registration and login page all

2条回答
  •  没有蜡笔的小新
    2021-01-15 06:14

    Right now your form is always empty and therefore invalid. You forgot to add the request POST content to the form.

    def SignUp(request):
        # ...
        if request.method == 'POST':
            regForm = SignupForm(request.POST)  # form needs content
            if regForm.is_valid():
                # ...
    

    If you get stuck when calling .is_valid(), you can print(regForm.errors) to see what's up.

提交回复
热议问题