如何覆蓋allauth.account.forms.BaseSignupForm
中的默認clean_email()
方法。 我試着在Forms.py如下:覆蓋Django-allauth中的clean_email()方法
from allauth.account.forms import BaseSignupForm
class Extended_BaseSignupForm(BaseSignupForm):
def clean_email(self):
data = self.cleaned_data['email']
if "@gmail.com" not in data: # any check you need
raise forms.ValidationError("Must be a gmail address")
if app_settings.UNIQUE_EMAIL:
if data and email_address_exists(data):
raise forms.ValidationError \
(_("A user is registered with this e-mail address."))
return data
壓倒一切的目的是爲了防止用戶一次性電子郵件ID註冊。
你應該粘貼完整的urls.py。 – jpic 2013-05-06 12:51:59