admin管理员组

文章数量:1433481

I am using Django all-auth in conjunction with django. I am also extending their default signup form. The form renders correctly, fields are validated correctly, the form returns as valid if checked but the save method isn't even called.

These are my settings, When the submit button is pressed, the form posts fine. But then no user is created and through some testing the save method on the form just isn't called.

forms.py

class CustomSignupForm(stupidform):

    agreed_to_TC = forms.BooleanField(required=True)
    agreed_to_PA = forms.BooleanField(required=False)
    agreed_to_updates = forms.BooleanField(required=False)
    email = forms.EmailField(required=True)
    password = forms.CharField(label='Password confirmation', widget=forms.PasswordInput)
    password2 = forms.CharField(label='Password confirmation', widget=forms.PasswordInput)

    def clean_password(self):
        password = self.cleaned_data["password"]
        password2 = self.cleaned_data.get("password2")
        if password and password2 and password != password2:
            raise ValidationError("Passwords don't match")
        return password

    def save(self, request):
        user = super(CustomSignupForm, self).save(request)
        user.email = self.cleaned_data["email"]
        user.agreed_to_ads = self.cleaned_data["agreed_to_PA"]
        user.agreed_to_TC = self.cleaned_data["agreed_to_TC"]
        user.save()
        return user

settings.py

AUTH_USER_MODEL = 'dashboard.UserProf'

ACCOUNT_USER_MODEL_USERNAME_FIELD = None
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_AUTHENTICATION_METHOD = 'email'

SECURE_SSL_REDIRECT = False
ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https"
ACCOUNT_EMAIL_REQUIRED = True
# ACCOUNT_EMAIL_VERIFICATION = "mandatory"


ACCOUNT_FORMS = {
'signup': 'wishfor.forms.CustomSignupForm',
}

urls

path('accounts/', include('allauth.urls')),

本文标签: Django allauth extended SignupForm is valid but save method is not calledStack Overflow