Skip to main content

Cloudflare Turnstile integration for Wagtail forms

Project description

Wagtail Turnstile

A lightweight Cloudflare Turnstile integration for Wagtail form pages.
Drop-in support with minimal configuration — and no Google reCAPTCHA required.

PyPI - Python Version License: MIT


Features

  • Adds a Turnstile field type to Wagtail’s form builder
  • Validates Turnstile submissions server-side

Installation

pip install wagtail-turnstile

Then add it to your Django settings:

INSTALLED_APPS = [
    ...
    "turnstile",
]

Add your Cloudflare Turnstile site and secret keys to your settings.py:

TURNSTILE_SITE_KEY = "your-site-key"
TURNSTILE_SECRET_KEY = "your-secret-key"

Usage

Here's a sample contact form page and field. Subclassing TurnstileAbstractFormField will add a new form field type, labelled to the user as "Captcha". This will handle the challenge and validation flow with Turnstile.

from turnstile.models import TurnstileAbstractFormField, TurnstileFormBuilder

class FormField(TurnstileAbstractFormField):
    page = ParentalKey(
        "ContactPage",
        on_delete=models.CASCADE,
        related_name="form_fields"
    )

class ContactPage(AbstractEmailForm):
    form_builder = TurnstileFormBuilder

Todo

Quite a lot, I would assume. It probably needs to be more customisable, and we don't need to store the Turnstile token.

Got any suggestions?

Feel free to raise an issue, and if you have a fix, submit a merge request and I'll be glad to take a look.

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

wagtail_turnstile-0.7.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

wagtail_turnstile-0.7.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file wagtail_turnstile-0.7.0.tar.gz.

File metadata

  • Download URL: wagtail_turnstile-0.7.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for wagtail_turnstile-0.7.0.tar.gz
Algorithm Hash digest
SHA256 00e91d5b3d6085544ae239c8b682abb43bdaa476027f091a50f8faea9b9cb072
MD5 8f7d1c5d751e08976870682f14a35914
BLAKE2b-256 0cc08d491a8525898f92b7d05b43b476ba7195b16de08b90920ed8b4014634e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for wagtail_turnstile-0.7.0.tar.gz:

Publisher: publish.yml on soundslocalcic/wagtail-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 wagtail_turnstile-0.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for wagtail_turnstile-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15c77c8fb0ebb662b0fb6749404b742fcbd7220171db861600a7bde03542307b
MD5 810c7690deda503d0611705a30c23936
BLAKE2b-256 e3ce4e2331633c06acb211c225dabc789dbf0af4be45b9ef1dd72ad216c010dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for wagtail_turnstile-0.7.0-py3-none-any.whl:

Publisher: publish.yml on soundslocalcic/wagtail-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