Skip to content

Instantly share code, notes, and snippets.

@mbmohib
Created November 23, 2016 17:08
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/f25e8b1f7976f46500a507e475a19951 to your computer and use it in GitHub Desktop.
Save mbmohib/f25e8b1f7976f46500a507e475a19951 to your computer and use it in GitHub Desktop.
Checking more than one filed exist or not!
def clean(self):
try:
User.objects.get(first_name=self.cleaned_data['first_name'],
last_name=self.cleaned_data['last_name'])
raise forms.ValidationError("Exists already!")
except User.DoesNotExist:
pass
return self.cleaned_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment