You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

forms.py 462B

123456789101112131415161718
  1. from django import forms
  2. from django.contrib.auth.models import User
  3. class GatewayForm(forms.Form):
  4. email = forms.EmailField()
  5. def clean_email(self):
  6. email = self.cleaned_data['email']
  7. try:
  8. User.objects.get(email=email)
  9. except User.DoesNotExist:
  10. pass
  11. else:
  12. raise forms.ValidationError(
  13. "A user already exists with email %s" % email
  14. )
  15. return email