Beispiel #1
0
 def clean_phone(self):
     # Check that the two password entries match
     phone = self.cleaned_data.get("phone")
     qs = User.objects.filter(phone=phone)
     if qs.exists():
         raise forms.ValidationErrors('Phone is already taken.')
     return phone
Beispiel #2
0
 def clean_email(self):
     email = self.cleaned_data.get('email')
     if email and User.objects.filter(email=email).exists():
         raise forms.ValidationError(
             "Email exists already. Please use a different email address.")
     if validate_email(email):
         #errors_list.append( ValidationError("Not a valiable email")
         raise forms.ValidationErrors("Not a valiable email")
     return email
Beispiel #3
0
 def clean(self):
     username = self.cleaned_data['username']
     password = self.cleaned_data['password']
     if not authenticate(username=username, password=password):
         raise forms.ValidationErrors("Invalid login")
Beispiel #4
0
 def clean_password_two(self):
     cd = self.cleaned_data
     if cd['password'] != cd['password_two']:
         raise forms.ValidationErrors('Entered Password Donot Match')
         #this is definately somethinf you do in the backend. use Javascript
     return cd['password_two']
Beispiel #5
0
 def clean(self):
     if self.is_valid():
         email = self.cleaned_data.get('email')
         password = self.cleaned_data.get('password')
         if not authenticate(email=email, password=password):
             raise forms.ValidationErrors('invalid login')