Get started


1 Aug 2023

Wagtail 5.1 gets a bit greener and leaner

Our latest release focuses on improving performance and reducing Wagtail's carbon footprint

Meagen Voss

Meagen Voss

Wagtail community manager

You're looking at a wagtail shooting through purple space on top of a rocket ship

We designed Wagtail to help everyone on a content team do the best work they can for their organizations. But we want to take that goal a step further. We want to help Wagtail users do their best work for our planet too.

In this release, we incorporated some improvements made through our collaboration with the Green Web Foundation and Google Summer of Code. We also updated compatibility for some key integrations, like Elasticsearch, trimmed some technical debt, and provided a few other features to help Wagtail run more smoothly behind the scenes.

Here are just a few of the things you can do with Wagtail 5.1:

Make your website greener with AVIF images

If you don't quite recognize AVIF yet, you're not alone. This modern image format kind of sounds like the nerdier cousin of GIF, but they aren't actually related. AVIF is a format supported by the Alliance for Open Media that has been shown to achieve much smaller file sizes than JPEG or another newer format called WEBP.

Chris Adams of the Green Web Foundation recommends using AVIF images as a part of his GOLD approach for reducing a website's carbon footprint. So it was pretty important for Wagtail to offer AVIF image support if we want to help people to make their Wagtail websites more sustainable. Smaller file sizes could mean smaller costs too for hosting and data storage. So content editors and website owners should be keen to embrace this new image format too, even if the acronym doesn't quite roll off the tongue the same way GIF does.

Generate image renditions more efficiently

A few changes in this release were made to help make image renditions more efficient. If you're wondering what image renditions are, think of them kind of like one of those online photo stores where you can upload an image of the one family vacation photo where everyone is actually smiling and then order different items like a tiny magnet photo for the fridge or a massive framed photo for the living room. Similarly, Wagtail can render images in multiple different sizes and shapes from the same image using image renditions.

Renditions can impact performance depending on how well they're managed, so this release introduces an AbstractImage.get_renditions() method that makes it a bit easier for developers to gather renditions and customize how they are processed. In this release, renditions are also now cached by default and changes were made to prevent memory exhaustion when updating a large number of image renditions.

Boost your Wagtail performance

In addition to adjusting the image caching, we made a few other performance changes in this release as well. We reworked permissions a lot in this release because we found the way they were being handled was leading to duplicated queries to the database. Based on some quick testing, the changes we made led to 50% fewer database queries when you use the Wagtail admin. We're looking forward to sharing some more exciting details about this work in a future post.

Install custom templates with the wagtail start command

We wanted to make it a little quicker for Wagtail developers to share and exchange custom templates for Wagtail. This release includes a new wagtail start command option for installing a template.

Here's how it's going to work. Whenever you start a new Wagtail project, you run a command like wagtail start my_blog in a terminal to get all of the project files set up. With this new command option, now you can type something like wagtail start my_blog --template wagtail-blog-starter in your terminal and the starter files for your custom frontend and backend can be set up. We're hoping this new feature helps people share ideas and templates more easily for Wagtail blocks, frontend configurations, and other useful Wagtail features.

Signpost important information with read-only admin panels

Anyone who has ever posted an editable document link on the Internet only to have it be taken over by memes and fart jokes will appreciate the importance of being able to use read-only panels in the Wagtail admin. Sometimes you just need to add important information or instructions to your Wagtail backend that only the developers on the team can update. Read-only panels will help keep others from inadvertently messing it up or editing by committee.

Improve your search with better Elasticsearch compatibility

Elasticsearch is a service (either paid or self-supported) that can help improve the quality of your website search. Wagtail now includes support for Elasticsearch 8 and the boost option – for increasing the ranking of certain search results using Elasticsearch – is supported for Elasticsearch 6 or above. Note though that Elasticsearch 5 and 6 are deprecated and will be removed in a future release. So maybe schedule that upgrade to Elasticsearch 7 sooner rather than later.

Things to watch out for

To improve performance, we spent a lot of time adjusting the way permissions are handled in Wagtail for this release. If you're using undocumented classes or functions for permissions (such as wagtail.models.UserPagePermissionsProxy), we have some new permissions classes and objects you will have to implement. We have a list of different methods you can use in your upgrade. We also simplified the GroupPagePermission model some by updating it to rely on Django's native Permission model.

One other big change developers will notice is that non-page models will be handled by wagtail.snippets instead of wagtail.contrib.modeladmin now. If you have code that relies on ModelAdmin, we've created a separate wagtail-modeladmin package you can use. Note though that wagtail.contrib.modeladmin will be removed in a future release. To help you prepare for that, we created a guide for migrating from ModelAdmin to Snippets.

Be sure to have a look at our full list of upgrade considerations as you charge ahead with updating your code as well the full release notes.

Need help with your upgrade?