开发者

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 开发者_StackOverflowother than numbers. However, it does not flag wrong answers. For example I input 2+1 = 6 and my registration completed just fine.

Any ideas?


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜