Commit e51560945a3afb0d13c6ec89a94da233a3f16031

Authored by ailsoncgt
1 parent 24f4066b

CPF validator #55

Showing 1 changed file with 7 additions and 0 deletions   Show diff stats
core/forms.py
... ... @@ -15,6 +15,13 @@ class RegisterUserForm(forms.ModelForm):
15 15 raise forms.ValidationError(_('There is already a registered User with this e-mail'))
16 16 return email
17 17  
  18 + def clean_cpf(self):
  19 + cpf = self.cleaned_data['cpf']
  20 + if User.objects.filter(cpf = cpf).exists():
  21 + raise forms.ValidationError(_('There is already a registeres User with this CPF'))
  22 + print(cpf)
  23 + return cpf
  24 +
18 25 def clean_password(self):
19 26 password = self.cleaned_data.get('password')
20 27  
... ...