Skip to main content

An easy-to-use math field/widget captcha for Django forms.

Project description

https://travis-ci.org/alsoicode/django-simple-math-captcha.svg

Current Version: 1.0.8

What is it?

A multi-value-field that presents a human answerable question, with no settings.py configuration necessary, but instead can be configured with arguments to the field constructor.

Installation

You can do any of the following to install django-simple-math-captcha

  • Run pip install django-simple-math-captcha.

  • Download or “git clone” the package and run setup.py.

  • Download or “git clone” the package and put the simplemathcaptcha directory on your PYTHONPATH.

Usage

Forms

To add the captcha field to your form:

from django import forms
from simplemathcaptcha.fields import MathCaptchaField

class MyForm(forms.Form):
    some_text_field = models.CharField(max_length=50)
    captcha = MathCaptchaField()

Optionally, you can pass in the following arguments to the field to configure it.

start_int

The number at which the field should begin its range of random numbers. This value will be used passed into the creation of a simplemathcaptcha.widgets.MathCaptchaWidget for this field.

Default value: 1

end_int

The number at which the field should end its range of random numbers. This value will be used passed into the creation of an simplemathcaptcha.widgets.MathCaptchaWidget for this field.

Default value: 10

error_messages

A dictionary of error messages. The keys you can use are invalid and invalid_number.

invalid

is the message to display when the provided answer is incorrect

Default value: "Check your math and try again."

invalid_number

is the message to display when the entry is not a whole number

Default value: "Enter a whole number."

question_tmpl

A string with format placeholders to use for the displayed question.

Default value: "What is %(num1)i %(operator)s %(num2)i?"

question_class

A css class to use for the span containing the displayed question.

Default value: "captcha-question"

widget

The widget instance to use, instead of the field creating an instance of simplemathcaptcha.widgets.MathCaptchaWidget. When provided, it must be an instatiated widget, not a widget class.

Additionally, when specifying widget, you must not specify start_int or end_int.

Default value: None

Rationale

Other math captcha fields can present questions that require decimal answers, answers that could be negative values and that require settings.py configuration. This project aims to provide a single field with minimal or no configuration necessary and reduce or prevent spam form submissions.

Status

django-simple-math-captcha is currently used in production.

Features

  • Simple addition, subtraction or multiplication question for captcha

  • No configuration necessary

  • Question asked changes with every render

  • Uses SHA1 hashing of answer with your SECRET_KEY

  • Unit tests are provided in the source

Requirements

  • Python 2.6+

  • Django 1.4+

License

The django-simple-math-captcha app is released under the Apache Public License v2.

Project details


Download files

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

Source Distribution

django-simple-math-captcha-1.0.8.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django-simple-math-captcha-1.0.8.tar.gz.

File metadata

  • Download URL: django-simple-math-captcha-1.0.8.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/18.5 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.10

File hashes

Hashes for django-simple-math-captcha-1.0.8.tar.gz
Algorithm Hash digest
SHA256 9cf7d882c5ad84e5be7dc8c463ddcb3f1606c46f23578bd522019b6f3dd67780
MD5 420a6241623888bbc52f60fc0388842b
BLAKE2b-256 5b8518515ab032cf748a4d87efda4de2b6e02e2af28512419f972618ec339af8

See more details on using hashes here.

File details

Details for the file django_simple_math_captcha-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: django_simple_math_captcha-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.5

File hashes

Hashes for django_simple_math_captcha-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 dbed5f92e9c60448d28104b5241f24c88b5cb3cb62e7213ff0e8b254d727855b
MD5 a7067ef530b90564cff11f833f88ea95
BLAKE2b-256 6326b48722c1573e4b18ec4f76440b926015b0cbbf851926aac2ec1ae50d660b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page