From e51560945a3afb0d13c6ec89a94da233a3f16031 Mon Sep 17 00:00:00 2001 From: ailsoncgt Date: Mon, 26 Sep 2016 10:53:59 -0300 Subject: [PATCH] CPF validator #55 --- core/forms.py | 7 +++++++ 1 file changed, 7 insertions(+), 0 deletions(-) diff --git a/core/forms.py b/core/forms.py index f8c1a7a..75ed40e 100644 --- a/core/forms.py +++ b/core/forms.py @@ -15,6 +15,13 @@ class RegisterUserForm(forms.ModelForm): raise forms.ValidationError(_('There is already a registered User with this e-mail')) return email + def clean_cpf(self): + cpf = self.cleaned_data['cpf'] + if User.objects.filter(cpf = cpf).exists(): + raise forms.ValidationError(_('There is already a registeres User with this CPF')) + print(cpf) + return cpf + def clean_password(self): password = self.cleaned_data.get('password') -- libgit2 0.21.2