class MathCaptchaForm(forms.Form): """ Subclass of ``django.forms.Form`` which contains the math fields. Inherit this class in your forms to add math captcha support:: class MyForm(MathCaptchaForm): field1 = forms.fields.CharField() # ... """ math_captcha_question = forms.fields.CharField(widget=NullWidget()) math_captcha_field = MathField(label=settings.QUESTION) def clean_math_captcha_field(self): math_clean(self)
class MathCaptchaModelForm(forms.ModelForm): """ Subclass of ``django.forms.ModelForm`` which contains the math fields Inherit this class in your forms to add math captcha support:: class MyForm(MathCaptchaModelForm): field1 = forms.fields.CharField() # ... class Meta: model = MyModel """ math_captcha_field = MathField(label=settings.QUESTION) math_captcha_question = forms.fields.CharField(widget=NullWidget()) def clean(self): super(MathCaptchaModelForm, self).clean() math_clean(self)