diff --git a/eshop/accounts_ext/forms.py b/eshop/accounts_ext/forms.py index 1c29a67..a66a677 100644 --- a/eshop/accounts_ext/forms.py +++ b/eshop/accounts_ext/forms.py @@ -56,12 +56,9 @@ class RegistrationForm(RegistrationFormUniqueEmail): raise forms.ValidationError(_('Введите email с валидными доменом')) return email - def clean_captcha(self): - captcha = super().clean_captcha() - if not captcha: - raise forms.ValidationError("Enter captcha") - print(captcha) - return captcha + def clean(self): + if self.captcha is None: + raise ValueError("Check captcha") def save(self, commit=True): user = super().save(commit) diff --git a/eshop/accounts_ext/views.py b/eshop/accounts_ext/views.py index 4a5141f..b03bc2a 100644 --- a/eshop/accounts_ext/views.py +++ b/eshop/accounts_ext/views.py @@ -23,7 +23,8 @@ from core.views import ProtectedTemplateView from .forms import ( PasswordResetRequestForm, SetPasswordForm, RegistrationCompanyForm, AuthenticationForm, - RegistrationForm) + RegistrationForm +) logger = logging.getLogger(__name__) @@ -105,6 +106,7 @@ class RegistrationView(RegistrationViewBase): new_user = self.register(form) context = self.get_context_data() company_form = context.get('company_form') + captcha_val = context.get('captcha') try: if company_form.is_valid(): company_form.save(user=new_user)