Skip to main content

Simple, secure math captcha for django forms(Django 1.6+ compatible)

Project description

Authors: Justin Quick <>
Version: 0.1.2

Note: this includes an update to a deprecated import in the file in order to make this Django 1.6+ compatible.

Django Math Captcha is an easy way to add mathematical captcha verification to your already existing forms. It asks you a simple math question (eg '1 + 2 =') and validates the form if your response is correct. All you have to do is subclass either MathCaptchaForm or MathCaptchaModelForm in your own forms.

Extending your forms:

from math_captcha import MathCaptchaModelForm
from myapp.forms import BlogForm

class MyExistingForm(BlogForm,MathCaptchaModelForm): # instead of forms.ModelForm
    #... extra fields here

Now you can be certain that the only users who create blogs are humans.

Check out the example project for more practical use and tests.

Using with other apps

If you are running an app like, say django-contact-form and want to add math captcha here is how to go about it.

Add the following in your

from contact_form.forms import ContactForm
from math_captcha.forms import MathCaptchaForm

class CaptchaContactForm(ContactForm,MathCaptchaForm):

urlpatterns = patterns('',
    url(r'^contact/sent/$','django.views.generic.simple.direct_to_template',{ 'template': 'contact_form/contact_form_sent.html' },name='contact_form_sent'),

Now the contact form will block robots who cant do math.


Set the behavior of the math captcha interaction in your


A list of numbers to randomly choose from when generating the questions. Defaults to 1 through 5.


String containing mathematical operators to use. Default is only add (+) and subtract (-). Available operators are: add (+), subtract (-), multiply (*), divide (/), and modulo (%)

MATH_CAPTCHA_QUESTION = 'Are you human?'

Question that appears on forms as a label for math questions. By default it is 'Are you human?'

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-math-captcha-update, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size django-math-captcha-update-0.1.2.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page