February 7, 2022
---
local:
depth: 1
---
This release adds support for Django 4.0.
As part of a wider redesign of Wagtail’s administration interface, we have replaced the sidebar with a slim, keyboard-friendly version. This re-implementation comes with significant accessibility improvements for keyboard and screen reader users, and will enable us to make navigation between views much snappier in the future. Please have a look at upgrade considerations for more details on differences with the previous version.
Wagtail projects using the wagtail.contrib.redirects
app now benefit from 'automatic redirect creation' - which creates redirects for pages and their descedants whenever a URL-impacting change is made; such as a slug being changed, or a page being moved to a different part of the tree.
This feature should be beneficial to most 'standard' Wagtail projects and, in most cases, will have only a minor impact on responsiveness when making such changes. However, if you find this feature is not a good fit for your project, you can disabled it by adding the following to your project settings:
WAGTAILREDIRECTS_AUTO_CREATE = False
Thank you to The National Archives for kindly sponsoring this feature.
page_slug_changed
signal for Pages (Andy Babic)StreamField
, StreamBlock
, and ListBlock
which will load all sub-blocks initially collapsed (Matt Westcott)alias_of
field to the pages API (Dmitrii Faiazov)default_app_config
deprecations for Django >= 3.2 (Tibor Leupold)search_fields
(LB (Ben Johnston))wagtail_site
template tag for Jinja2 (Vladimir Tananko)first_published_date
and last_published_date
(Dan Braghis)WAGTAILADMIN_USER_LOGIN_FORM
are now rendered correctly (Michael Karamuth)ol
items are not cut off (Khanh Hoang)(2.16_upgrade_considerations)=
Django 3.0 and 3.1 are no longer supported as of this release; please upgrade to Django 3.2 or above before upgrading Wagtail.
Python 3.6 is no longer supported as of this release; please upgrade to Python 3.7 or above before upgrading Wagtail.
ListValue
rather than a list instanceThe data type returned as the value of a ListBlock is now a custom class, ListValue
, rather than a Python list
object. This change allows it to provide a bound_blocks
property that exposes the list items as BoundBlock
objects rather than plain values. ListValue
objects are mutable sequences that behave similarly to lists, and so all code that iterates over them, accesses individual elements, or manipulates them should continue to work. However, code that specifically expects a list
object (e.g. using isinstance
or testing for equality against a list) may need to be updated. For example, a unit test that tests the value of a ListBlock
as follows:
self.assertEqual(page.body[0].value, ['hello', 'goodbye'])
should be rewritten as:
self.assertEqual(list(page.body[0].value), ['hello', 'goodbye'])
set
method on tag fieldsThis release upgrades the django-taggit library to 2.x, which introduces one breaking change: the TaggableManager.set
method now accepts a list of tags as a single argument, rather than a variable number of arguments. Code such as page.tags.set('red', 'blue')
should be updated to page.tags.set(['red', 'blue'])
.
wagtail.admin.views.generic.DeleteView
follows Django 4.0 conventionsThe internal (undocumented) class-based view wagtail.admin.views.generic.DeleteView
has been updated to align with Django 4.0's DeleteView
implementation, which uses FormMixin
to handle POST requests. Any custom deletion logic in delete()
handlers should be moved to form_valid()
.
admin/expanding_formset.js
has been renamed to admin/expanding-formset.js
as part of frontend code clean up work. Check for any customised admin views that are extending expanding formsets, or have overridden template and copied the previous file name used in an import as these may need updating.
The new sidebar largely supports the same customisations as its predecessor, with a few exceptions:
icon_name
, so they can be visually distinguished when the sidebar is collapsed.MenuItem
and its sub-classes no longer supports customising arbitrary HTML attributes.MenuItem
can no longer be sub-classed to customise its HTML output or load additional JavaScriptFor sites relying on those capabilities, we provide a WAGTAIL_SLIM_SIDEBAR = False
setting to switch back to the legacy sidebar. The legacy sidebar and this setting will be removed in Wagtail 2.18.