您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

forms.py 476B

12345678910111213141516
  1. from django import forms
  2. from django.contrib.auth.models import User
  3. from oscar.apps.customer.utils import normalise_email
  4. class GatewayForm(forms.Form):
  5. email = forms.EmailField()
  6. def clean_email(self):
  7. email = normalise_email(self.cleaned_data['email'])
  8. if User.objects.filter(email__iexact=email).exists():
  9. raise forms.ValidationError(
  10. "A user already exists with email %s" % email
  11. )
  12. return email