Package: wagtail-django-simple-captcha
Wagtail forms with a Captcha form field/widget integration app. Wagtail Simple Captcha provides an easy way to integrate thedjango-simple-captchafield when using the Wagtail formbuilder.This app is a modification ofwagtail-django-recaptchaby Springload.Check outAwesome Wagtailfor more awesome packages and resources from the Wagtail community.InstallationInstall wagtailcaptcha via pippip installwagtail-django-simple-captchaor addwagtailcaptchato your Python path.Addwagtailcaptchaandcaptchato yourINSTALLED_APPSsetting.Configure django-simple-captcha as explained inhere.UsageFieldThe quickest way to add a captcha field to a Wagtail Form Page is to inherit from the two options provided,WagtailCaptchaFormorWagtailCaptchaEmailForm. The first options inherits fromAbstractFormwhile the seconds does it fromAbstractEmailForm. Either way your page is going to display a captcha field at the end of the form.Example:fromwagtail.contrib.forms.modelsimportAbstractFormFieldfromwagtail.admin.edit_handlersimportFieldPanel,InlinePanel,MultiFieldPanelfromwagtail.core.fieldsimportRichTextField# Or, if using Wagtail < 2.0#from wagtail.wagtailforms.models import AbstractFormField#from wagtail.wagtailadmin.edit_handlers import FieldPanel, InlinePanel, MultiFieldPanel#from wagtail.wagtailcore.fields import RichTextFieldfrommodelcluster.fieldsimportParentalKeyfromwagtailcaptcha.modelsimportWagtailCaptchaEmailFormclassSubmitFormField(AbstractFormField):page=ParentalKey('SubmitFormPage',related_name='form_fields')classSubmitFormPage(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.')classMeta: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 customize the behavior of the form builder, make sure to inherit fromwagtailcaptcha.forms.WagtailCaptchaFormBuilderinstead of Wagtail’s default form builder, then declare it as usual on the page model:fromwagtailcaptcha.formsimportWagtailCaptchaFormBuilderfromwagtailcaptcha.modelsimportWagtailCaptchaFormclassCustomFormBuilder(WagtailCaptchaFormBuilder):# Some custom behavior...classFormPage(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 the module in which this app is based from.DevelopmentInstallationRequirements:virtualenv,pyenv,twinegitclonegit@github.com:acarasimon96/wagtail-django-simple-captcha.gitcdwagtail-django-simple-captcha/virtualenv.venvsource./.venv/bin/activatemakeinitCommandsUsemake helpto get a list of commands.Copyright© 2020 Timothy Bautista. Original code © 2016 Springload. Licensed under MIT License