A simple recaptcha field for Wagtail Form Pages.
Project description
Wagtail ReCaptcha
Wagtail forms with a ReCaptcha form field/widget integration app. Wagtail ReCaptcha provides an easy way to integrate the django-recaptcha field when using the Wagtail formbuilder.
Check out Awesome Wagtail for more awesome packages and resources from the Wagtail community.
Compatibility
- Django 5.2, 6.0
- Wagtail 7.0 LTS, 7.3
- Python 3.10, 3.11, 3.12, 3.13, 3.14
Installation
- Install wagtailcaptcha via pip
pip install wagtail-django-recaptchaor addwagtailcaptchato your Python path. - Add
wagtailcaptchato yourINSTALLED_APPSsetting. - Configure django-recaptcha as explained in the django recaptcha documentation.
Usage
Field
The quickest way to add a captcha field to a Wagtail Form Page is to inherit from the two options provided, WagtailCaptchaForm or WagtailCaptchaEmailForm. The first options inherits from AbstractForm while the seconds does it from AbstractEmailForm. Either way your page is going to display a captcha field at the end of
the form.
Example
from wagtail.contrib.forms.models import AbstractFormField
from wagtail.admin.panels import FieldPanel, InlinePanel, MultiFieldPanel
from wagtail.fields import RichTextField
from modelcluster.fields import ParentalKey
from wagtailcaptcha.models import WagtailCaptchaEmailForm
class SubmitFormField(AbstractFormField):
page = ParentalKey('SubmitFormPage', related_name='form_fields')
class SubmitFormPage(WagtailCaptchaEmailForm):
body = RichTextField(blank=True, help_text='Edit the content you want to see before the form.')
thank_you_text = RichTextField(blank=True, help_text='Set the message users will see after submitting the form.')
class Meta:
verbose_name = "Form submission page"
SubmitFormPage.content_panels = [
FieldPanel('title', classname="full title"),
FieldPanel('body', classname="full"),
FieldPanel('thank_you_text', classname="full"),
InlinePanel('form_fields', label="Form fields"),
MultiFieldPanel([
FieldPanel('to_address'),
FieldPanel('from_address'),
FieldPanel('subject'),
], "Email notification")
]
The captcha field can't be added from the admin UI but will appear in your frontend as the last of the form fields.
If you need to customise the behaviour of the form builder, make sure to inherit from wagtailcaptcha.forms.WagtailCaptchaFormBuilder instead of Wagtail's default form builder, then declare it as usual on the page model.
from wagtailcaptcha.forms import WagtailCaptchaFormBuilder
from wagtailcaptcha.models import WagtailCaptchaForm
class CustomFormBuilder(WagtailCaptchaFormBuilder):
# Some custom behaviour...
class FormPage(WagtailCaptchaForm):
form_builder = CustomFormBuilder
# The rest of the page definition as usual...
For a more thorough example, Made with Wagtail (github.com/springload/madewithwagtail) is an example of an open-source site using this module.
Development
Installation
Requirements:
virtualenv,pyenv,twine
git clone git@github.com:wagtail-nest/wagtail-django-recaptcha.git
cd wagtail-django-recaptcha/
virtualenv .venv
source ./.venv/bin/activate
Commands
Use make help to get a list of commands.
Releases
- Make a new branch for the release of the new version.
- Update the CHANGELOG.
- Update the version number in
wagtailcaptcha/__init__.py, following semver. - Make a PR and squash merge it.
- Back on
masterwith the PR merged, usemake publish(confirm, and enter your password). - Finally, go to GitHub and create a release and a tag for the new version.
- Done!
Acknowledgements
Wagtail ReCaptcha was originally created by Springload. They kindly transferred the project to the Wagtail Nest community in December 2024.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wagtail_django_recaptcha-2.2.0.tar.gz.
File metadata
- Download URL: wagtail_django_recaptcha-2.2.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7340ba346f365f475595b733c4f4ef380bd2e331261d5a5604b57baa3a7b786
|
|
| MD5 |
b99ba3548329485d6c3bf9804b2b7889
|
|
| BLAKE2b-256 |
aebaca504c45123f07314a0cd83a03c5b3872c3e851e703f0a6ea92fbf6f2e10
|
Provenance
The following attestation bundles were made for wagtail_django_recaptcha-2.2.0.tar.gz:
Publisher:
publish.yml on wagtail-nest/wagtail-django-recaptcha
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wagtail_django_recaptcha-2.2.0.tar.gz -
Subject digest:
d7340ba346f365f475595b733c4f4ef380bd2e331261d5a5604b57baa3a7b786 - Sigstore transparency entry: 1338836283
- Sigstore integration time:
-
Permalink:
wagtail-nest/wagtail-django-recaptcha@ac3cd8b750fc8e8be794a91e4398914f300d35f7 -
Branch / Tag:
refs/tags/v2.2.0 - Owner: https://github.com/wagtail-nest
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ac3cd8b750fc8e8be794a91e4398914f300d35f7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file wagtail_django_recaptcha-2.2.0-py3-none-any.whl.
File metadata
- Download URL: wagtail_django_recaptcha-2.2.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
094a59cbfd9f02d41e9fd0a294fc3e754e5b5fc5da01cc15a8e08007f3ad2f67
|
|
| MD5 |
e5cb5f0f66da851948544d34f90f13b8
|
|
| BLAKE2b-256 |
856e51b0f5be85c42364b325ef623cbd7fbc038c10bc3d11fb75b6acfe09cc35
|
Provenance
The following attestation bundles were made for wagtail_django_recaptcha-2.2.0-py3-none-any.whl:
Publisher:
publish.yml on wagtail-nest/wagtail-django-recaptcha
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wagtail_django_recaptcha-2.2.0-py3-none-any.whl -
Subject digest:
094a59cbfd9f02d41e9fd0a294fc3e754e5b5fc5da01cc15a8e08007f3ad2f67 - Sigstore transparency entry: 1338836285
- Sigstore integration time:
-
Permalink:
wagtail-nest/wagtail-django-recaptcha@ac3cd8b750fc8e8be794a91e4398914f300d35f7 -
Branch / Tag:
refs/tags/v2.2.0 - Owner: https://github.com/wagtail-nest
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ac3cd8b750fc8e8be794a91e4398914f300d35f7 -
Trigger Event:
release
-
Statement type: