Skip to main content

django-simple-math-captcha

Current Version: 2.0.1

For Django 4, use 2.0.x. For Django < 4, use 1.1.0

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.

Add simplemathcaptcha to your INSTALLED_APPS in django settings

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

Compatibility

For any version of Django that doesn’t support Python 3, use django-simple-math-captcha 1.0.9 or below, otherwise use 1.1.0 or above.

License

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

Metadata

Release files for django-simple-math-captcha 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-simple-math-captcha 2.0.1
File Size Uploaded Provenance Actions
django-simple-math-captcha-2.0.1.tar.gz 8.6 kB Without provenance Details for django-simple-math-captcha-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-simple-math-captcha 2.0.1
File Interpreter ABI Platform Actions
django_simple_math_captcha-2.0.1-py2-none-any.whl Python 2 none any Details for django_simple_math_captcha-2.0.1-py2-none-any.whl

Total release size: 22.5 kB

Release files / django-simple-math-captcha-2.0.1.tar.gz

Download URL django-simple-math-captcha-2.0.1.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5363a4754dad461b22324668032e08422dc9a5ef611d35950fd3da92a87d1ad3
BLAKE2b-256 checksum
How to use checksums
0c0893717866549f7b5355842e4e9e7d08be16212827ed16de3544d97c01399c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

Release files / django_simple_math_captcha-2.0.1-py2-none-any.whl

Download URL django_simple_math_captcha-2.0.1-py2-none-any.whl
Size 13.9 kB
Tags Python 2
SHA-256 checksum
How to use checksums
7e14a9bae635fce0824aeb51df7004d733d7ab41c8108514474ed09588181ddf
BLAKE2b-256 checksum
How to use checksums
ea0f25f3be92cdc78c3f5a1abdb709039c8bd515ac4104f83d70caf56bc99c9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

Security for django-simple-math-captcha 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page