lightjitender

forms.py

Sep 13th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. class emailforms(forms.ModelForm):
  2.     email = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'}),
  3.                             max_length=200,
  4.                             required=True,
  5.                             )
  6.  
  7.     def clean(self):
  8.         email_data=self.cleaned_data['email']
  9.         try:
  10.             match = Userdetails.objects.get(email=email_data)
  11.         except:
  12.             return self.cleaned_data.get('email')
  13.         raise forms.ValidationError("already exis")
  14.     class Meta:
  15.             model=Userdetails
  16.             fields=['email']
Add Comment
Please, Sign In to add comment