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.3.2.tar.gz (10.1 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.3.2-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wagtail_turnstile-0.3.2.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for wagtail_turnstile-0.3.2.tar.gz
Algorithm Hash digest
SHA256 3c0aa7a348cc5a7680fee550093eccc07e61c4adff5419fb3a6edc51444e42bd
MD5 55a7b46c4dc1d0a8866c3e88a8217cf3
BLAKE2b-256 e9e85af9c70710056e8f71b9b71010c5afaa2597044b5c165f4b894960720413

See more details on using hashes here.

File details

Details for the file wagtail_turnstile-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for wagtail_turnstile-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 75e54f9a8006713350fde9127b4f8a4596152d3b27caa77438511c62b169edff
MD5 aee1c3a581da999e7d6fd0d4d6e71447
BLAKE2b-256 b5b76d6da027afcb6ac6f2407cbe901f5bdd8d3ff4992353a50af38ebeb4536c

See more details on using hashes here.

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