From ddd90e650b253208629c54101ae301be706cc28d Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 18 Dec 2019 22:54:10 +0530 Subject: [PATCH] Add clean_name method for BillingAddressFormSignup --- utils/forms.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/utils/forms.py b/utils/forms.py index f4588654..1559b325 100644 --- a/utils/forms.py +++ b/utils/forms.py @@ -175,6 +175,14 @@ class BillingAddressFormSignup(BillingAddressForm): except CustomUser.DoesNotExist: return email + def clean_name(self): + name = self.cleaned_data.get('name') + try: + validate_name(name) + except ValidationError as ve: + raise forms.ValidationError(_("Improper Name")) + return name + class UserBillingAddressForm(forms.ModelForm): user = forms.ModelChoiceField(queryset=CustomUser.objects.all(),