Tutorial Wagtail Version: 2.x
Contact forms are notorious for collecting spam from bots. In this tutorial we'll install a package to automatically add Google Recaptcha to our contact forms. We'll explore how to get the API keys, as well.
Most websites need a contact form so users can get in touch with the people who run, maintain and operate a website. But there's a lurking danger around the corner: bots. These annoying, automated, and sometimes very sophisticated programs will scrape your website and try to submit forms. If it's a login form, it'll try to guess common login credentials. If it's a contact form, it'll spam you annoying messages about various adult subjects.
In this tutorial, we install a package called wagtail-django-recaptcha. This allows us to add a Google Recaptcha to our contact form and reduce the number of fake form submissions.
It won't remove 100% of all spam submissions, but it will drastically reduce them to a manageable state. And if you're building websites for clients, this will make them much happier.
In total, this should take you less than 10 minutes to install.
First things first, install the package.
pip install wagtail-django-recaptcha
Next you'll need to enable the app in your Django application.
At this point, you have the recaptcha package installed in your Django. Next, head on over to google.com/recaptcha and get some API keys. If you're uncertain about how to do that, I cover all of it in the video.
After you've gotten your API credentials from Google, apply them to your base.py
settings file. And disable NOCAPTCHA
.
Lastly, you'll need to change your Contact Page model. If you don't have a Contact Form Page yet, see this tutorial: Contact Forms. Below is the full code to get up and running with a Contact Form that uses a Recaptcha.
Create a new Contact Page and view it in your browser, and you should see this image
This package and repo, the one for wagtail-django-recaptcha, is maintained by Springload. They do great things with Wagtail so make sure you check out their entire GitHub organization.
If you just want to git commit, you can find it here: https://github.com/CodingForEverybody/learn-wagtail/commit/49a73bea1c2505f408b39c2ba0cc097af4bc91d1
21. Adding Editable Forms with reCAPTCHA
Posted on
Contact Forms
Posted on
Contact forms are an essential part of many websites. Wagtail gives us a lot of powerful features without having to do very much work. In this tutorial we're going to create a contact form and a contact form landing page. The contact form will have 3 completely custom fields that the content editor can manage on their own. We'll also explore the Forms feature in the Wagtail Admin.
Adding Global Site Settings to Your Wagtail Website
Posted on
Most websites have social media icons in their footer and often several other links and icons that are global across the entire website. In this video we explore how to enable that with Wagtails settings context processor.
Adding User Registration/Login To Your Wagtail Website
Posted on
Learn how to add user authentication and give your users the ability to signup, login, reset their password and confirm their email addresses.
This course covers everything from basic installation to advanced features like custom blocks and API integration, it's perfect for developers looking to enhance their skills with this powerful CMS.