Tutorial Wagtail Version: 2.x
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.
Subclassing is a darn nice feature in Object Orientated Programming. It lets you write re-useable code in several places; much like a function, but bigger.
The great thing about subclassing Page's in Wagtail is reusability; you can create one "master" or "parent" page and let other pages inherit from it (child pages). All the children will share common attributes from the parent page, but then you can extend each child to be unique by adding custom fields and methods.
The analogy I like to use is a real family.
You share personality traits with your mother and father. If you have siblings, they will have similar personality traits to all of you. All of these common personality traits come from your parents, that's where they begin. And as their offspring, you'll maintain a lot of traits throughout your life, but you'll also grow into your own person. When you grow into your own person you'll gain new perspective, skills and personality traits. Or in the land of OOP, you'll have new properties, methods and purposes.
Below is a copy and paste snippet of code you can use as a reference in your projects to immediately make 3 blog pages: one parent, and two child pages.
The entire Git Commit can be found here: https://github.com/CodingForEverybody/learn-wagtail/commit/cbf0767201e760d96e2925354be2f28c0f8b820a
How to Paginate Your Wagtail Pages
Posted on
Pagination is the ability to click through "pages". You most commonly see this on a Blog Listing Page, where you have "page 1 of 4" for example. In this lesson we're going to use Django Paginator right out of the box to add pagination to our Wagtail Blog Listing Page. No 3rd party packages, no craziness, and minimal maintenance. Just beautiful Wagtail and Django working together in 11 lines of code in our Wagtail Page Pagination.
How to Deploy Wagtail to Heroku
Posted on
Learn how to deploy a brand new Wagtail site to a free Heroku instance.
Adding Tags to Pages
Posted on
In this tutorial we'll discover how to add Tags (with an autocomplete feature) to Wagtail Pages. We'll also learn how to filter blog posts by a certain tag.
How to Install Wagtail with Docker
Posted on
In this article we're going to learn how to get a Wagtail website setup and running with Docker.
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.