Tutorial Wagtail Version: 2.x
Snippets are Wagtails way of re-using existing data. For example, being able to select a Blog Author (or multiple authors) instead of having to add a name, image and website for every blog author in every blog post you make; instead you can simply fill out a form once, and re-use the final data with a couple of clicks.
"Snippets are pieces of content which do not necessitate a full webpage to render."
Above is the line from the Wagtail Docs that describes a Snippet. It's accurate, but maybe a bit tricky to understand at first.
You can think of a Snippet like pieces of data that you can re-use. If you're familiar with the coding notion of functions (re-usable chunks of code), then you can think of a Snippet as a function for storing and retrieving data from the Wagtail Admin.
Some example where Snippets are useful:
In this video we'll be using Blog Authors as the the example. Here's a copy & paste example you can use:
Videos not your thing? That's OK. Here's the link the full Git Commit so you can see what was added in this video at a glance.
https://github.com/CodingForEverybody/learn-wagtail/commit/de5e86e29802c1548cabb148ca0e41dafcfe928d
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.
Using a SnippetChooserPanel to Select Multiple Blog Authors (Snippets + Orderables)
Posted on
This is part 2, coming from the previous article/video. In this lesson we'll be using a SnippetChooserPanel to select Blog Authors (a snippet we registered last episode). We'll also add in an Orderable to our Blog Detail Page so we can select between 1 and 4 Blog Authors.
How to Register a Django Model with Wagtails ModelAdmin
Posted on
In the land of Django and Wagtail, sometimes you need custom Django Models but Wagtail doesn't let you edit these models by default. And personally, I don't believe in giving a client 2 admin dashboards to operate in. So let's add a custom Django Model to our Wagtail website using a Wagtail ModelAdmin.
Headless CMS: Custom Wagtail Image Serializer
Posted on
Using Django Rest Framework with Wagtails v2 API, we can customize ANY field the way we want. In this short video, we take a look at creating a new field entirely by overwriting an image, but we also look at serializing (JSONifying) an image field from a ForeignKey inside an Orderable. Don't worry, it's not as crazy as it sounds!
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.