New Wagtail Course! 🥳 The Ultimate Wagtail Developers Course

Tutorial Wagtail Version: 2.x

Customizing Default Property Values

In this tutorial we are going to learn how to customize default Wagtail Page properties by changing the default help text and field verbose names. We'll also learn how to set a new default field value when you create a new Wagtail Page.

Below is the exact code you'll find in this Git Commit.

``` class HomePage(Page): ... # This is your HomePage model ... # This will change the "title" field 's verbose name to "Custom Name". # But you'd still reference it in the template as `page.title` HomePage._meta.get_field("title").verbose_name = "Custom Name" # Here we are removing the help text. But to change it, simply change None to a string. HomePage._meta.get_field("title").help_text = None # Below is the new default title for a Home Page. # This only appears when you create a new page. HomePage._meta.get_field("title").default = "Default HomePage Title" # Lastly, we're adding a default `slug` value to the page. # This does not need to reflect the same (or similar) value that the `title` field has. HomePage._meta.get_field("slug").default = "default-homepage-title" ```

Related tutorials

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!

View lesson, Headless CMS: Custom Wagtail Image Serializer

How to only get Parent and Child Class Pages and their Specific Fields

Posted on

When querying for a Wagtail Page that has child (Subclassed) pages, you'll receive all of the pages in your QuerySet. There are times when you simply want the child pages (all types), a specific type of child page, or just the parent page itself with no children. In this lesson we'll explore Wagtails .not_exact_type() and .exact_type() methods.

View lesson, How to only get Parent and Child Class Pages and their Specific Fields

Headless CMS: Custom Page Properties

Posted on

If you want to add data custom data (or a function output) to your headless Wagtail API, you can use a @property. In this tutorial I'll show you how easy it can be!

View lesson, Headless CMS: Custom Page Properties

Adding Custom CSS and JavaScript to Your Admin Area

Posted on

Customizing the styling and adding some additional JavaScript functionality to your Wagtail Admin (backend) is often a good idea for user experience and a higher perceived value for clients. In this tutorial I'll show you how to add a custom .css and .js file to your /admin/ area so you can give your clients a truly customized experience.

View lesson, Adding Custom CSS and JavaScript to Your Admin Area

The Ultimate Wagtail Developers Course

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.

Ultimate Wagtail Developers Course Logo