Skip to content

Instantly share code, notes, and snippets.

@mbmohib
Created November 23, 2016 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbmohib/900d71e53af1390ae22b55e9ad5bd782 to your computer and use it in GitHub Desktop.
Save mbmohib/900d71e53af1390ae22b55e9ad5bd782 to your computer and use it in GitHub Desktop.
In registration menu, checking email already exist or not!
def clean_email(self):
email = self.cleaned_data.get('email')
username = self.cleaned_data.get('username')
if email and User.objects.filter(
email=email).exclude(username=username).count():
raise forms.ValidationError(
"A user with that email already exists")
return email
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment