admin管理员组文章数量:1024073
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')),
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
版权声明:本文标题:Django all-auth extended SignupForm is valid but save method is not called - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745583033a2157421.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论