Skip to main content

A Django app for integrating Cloudflare Turnstile into forms.

Project description

django-cf-turnstile

django-cf-turnstile is a Django app for integrating Cloudflare Turnstile captchas into django forms.

Note that django-cf-turnstile only supports implicit rendering of widgets.

Requirements

  • Python: 3.10+
  • Django: 4.2+

Installation

Install the package with:

pip install django-cf-turnstile

Add "django_cf_turnstile" to your INSTALLED_APPS setting.

INSTALLED_APPS = [
   ...,
   "django_cf_turnstile",
]

Add your Turnstile site key and secret to your django settings.

# django-cf-turnstile
# Dummy keys used below, replace with your actual keys

CF_TURNSTILE_SITE_KEY = "1x00000000000000000000AA"
CF_TURNSTILE_SECRET_KEY = "1x0000000000000000000000000000000AA"

Note that if you don't provide a site key and secret key the test site keys which always pass validation will be used.

For more information on test keys see https://developers.cloudflare.com/turnstile/troubleshooting/testing/.

Usage

In your Django forms import and use TurnstileCaptchaField

from django import forms
from django_cf_turnstile.fields import TurnstileCaptchaField


class CaptchaSignupForm(forms.Form):
    ...
    captcha = TurnstileCaptchaField()

Customization

Overriding Keys

Keys may be overridden on individual forms by passing in site_key and secret_key.

class CaptchaSignupForm(forms.Form):
    captcha = TurnstileCaptchaField(
       site_key="3x00000000000000000000FF",
       secret_key="1x0000000000000000000000000000000AA"
    )

Adding Labels

By default, the label is set to an empty string. This can be overridden by setting label.

class CaptchaSignupForm(forms.Form):
    captcha = TurnstileCaptchaField(label="Captcha")

Credits

Inspired by django-recaptcha

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_cf_turnstile-0.1.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_cf_turnstile-0.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file django_cf_turnstile-0.1.0.tar.gz.

File metadata

  • Download URL: django_cf_turnstile-0.1.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for django_cf_turnstile-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bdc2e06d2dd75d18f6be53436c4a58b467cac7f0ef7737989c4eaa814b9d6b5f
MD5 b4040f9f883944d0f6b345f93817d224
BLAKE2b-256 579709cd52730e58d9a227802b779a397c7705c287429f9cbab2084bcdda6ac4

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_cf_turnstile-0.1.0.tar.gz:

Publisher: pypi-publish.yml on ronaldgrn/django-cf-turnstile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_cf_turnstile-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_cf_turnstile-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2acfcda3cb85eefb43da63bddbc833776fbd901726d1b1e744eee5f1009d197f
MD5 36673c90f2d18bb592597cd0d93e3ebd
BLAKE2b-256 7aec92abc03db369177f12b5685ee96aa3706d194ad1d45ac918f1d07f124689

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_cf_turnstile-0.1.0-py3-none-any.whl:

Publisher: pypi-publish.yml on ronaldgrn/django-cf-turnstile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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