Wagtail 2.11.3 release notes¶
December 10, 2020
What’s new¶
Bug fixes¶
Updated project template migrations to ensure that initial homepage creation runs before addition of locale field (Dan Braghis)
Restore ability to use translatable strings in
LANGUAGES
/WAGTAIL_CONTENT_LANGUAGES
settings (Andreas Morgenstern)Allow
locale
/translation_of
API filters to be used in combination with search (Matt Westcott)Prevent error on
create_log_entries_from_revisions
when checking publish state on a revision that cannot be restored (Kristin Riebe)
Upgrade considerations¶
run_before
declaration needed in initial homepage migration¶
The migration that creates the initial site homepage needs to be updated to ensure that will continue working under Wagtail 2.11. If you have kept the home
app from the original project layout generated by the wagtail start
command, this will be home/migrations/0002_create_homepage.py
. Inside the Migration
class, add the line run_before = [('wagtailcore', '0053_locale_model')]
- for example:
# ...
class Migration(migrations.Migration):
run_before = [
('wagtailcore', '0053_locale_model'), # added for Wagtail 2.11 compatibility
]
dependencies = [
('home', '0001_initial'),
]
operations = [
migrations.RunPython(create_homepage, remove_homepage),
]
This fix applies to any migration that creates page instances programmatically. If you installed Wagtail into an existing Django project by following the instructions at Integrating Wagtail into a Django project, you most likely created the initial homepage manually, and no change is required in this case.
Further background: Wagtail 2.11 adds a locale
field to the Page model, and since the existing migrations in your project pre-date this, they are designed to run against a version of the Page model that has no locale
field. As a result, they need to run before the new migrations that have been added to wagtailcore
within Wagtail 2.11. However, in the old version of the homepage migration, there is nothing to ensure that this sequence is followed. The actual order chosen is an internal implementation detail of Django, and in particular is liable to change as you continue developing your project under Wagtail 2.11 and create new migrations that depend on the current state of wagtailcore
. In this situation, a user installing your project on a clean database may encounter the following error when running manage.py migrate
:
django.db.utils.IntegrityError: NOT NULL constraint failed: wagtailcore_page.locale_id
Adding the run_before
directive will ensure that the migrations run in the intended order, avoiding this error.