rabbid
rabbid

Reputation: 5725

django-registration with django-math-captcha

Has anyone ever successfully integrated django-math-captcha into django-registration?

I've changed the form in django-registration to be as such:

class RegistrationForm(MathCaptchaForm)

The form displays just fine, and it recognizes when I input anything other than numbers. However, it does not flag wrong answers. For example I input 2+1 = 6 and my registration completed just fine.

Any ideas?

Upvotes: 2

Views: 621

Answers (1)

rabbid
rabbid

Reputation: 5725

To answer my own question, it is because MathCaptchaForm.clean() was being overridden by RegistrationForm.clean(). I called super() from within RegistrationForm.clean() and it worked.

New code within RegistrationForm.clean():

def clean(self):
    super(RegistrationForm, self).clean()

    if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data:
        if self.cleaned_data['password1'] != self.cleaned_data['password2']:
            raise forms.ValidationError(_("The two password fields didn't match."))

    return self.cleaned_data

Upvotes: 2

Related Questions