Tutorial Wagtail Version: 2.x
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.
Most websites have some type of contact form. Whether it's for support or some other reason, there's usually a way to get in touch with a websites maintainer.
Contact forms can be a hassle though. But in this tutorial I'll show you how to add an email form for your Wagtail site. It's super easy, and there are lots of goodies out of the box.
First things first, you'll need to make sure you have wagtail.contrib.forms
in your INSTALLED_APPS
Next you'll need to create two classes. One will handle the email fields, and one will be your actual Wagtail Page.
When you're done with that, make sure you run python manage.py makemigrations
and python manage.py migrate
There are two templates you're going to work with.
Lastly you'll need to create a new Contact Page from inside the Wagtail Admin. Add the fields you'd like to display. And that's it!
The full git commit can be found here: https://github.com/CodingForEverybody/learn-wagtail/commit/d67bc5659ca023c21d8a9f01d30604f6d67cd2d6. Note: the git commit has Bootstrap 4 styling in it, and the code above (in this tutorial) has all the BS4 styling stripped out.
Adding Recaptcha to Your Contact Forms
Posted on
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.
Registering Snippets (Blog Category) using Checkboxes
Posted on
In this tutorial we'll be learning how to register another Wagtail Snippet, but instead of using an Orderable and a SnippetChooserPanel (like the previous lesson) we're going to use a ParentalManyToManyField and a form widget to create Checkboxes in the Wagtail Admin.
Restricting Parent and Child Pages
Posted on
When you start to create several different page types in Wagtail and you create a child page (a page that's nested under a different page) you'll see every single page is an option. In this video we'll explore how to restrict where pages can live by telling the parent page what types of child page(s) they should expect, and by telling the child pages which parent page(s) they can expect.
How to Subclass Wagtail Pages
Posted on
Subclassing is having a class (in this case it's a Wagtail Page) that can be used for other classes (Wagtail Page's). The parent class has all the common attributes for the child pages, and every child page will inherit everything from it's parent. In this lesson we'll explore that by creating a subclassed Article and Video Blog Page that share a common parent, and then we'll extend the functionality of both subclassed pages by adding new fields.
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.