Skip to content

fix: update Wagtail to 7.4 LTS#2159

Merged
SaptakS merged 8 commits into
developfrom
fix/wagtail74
May 18, 2026
Merged

fix: update Wagtail to 7.4 LTS#2159
SaptakS merged 8 commits into
developfrom
fix/wagtail74

Conversation

@paulschreiber
Copy link
Copy Markdown
Contributor

@paulschreiber paulschreiber commented May 5, 2026

Description

Update Wagtail 6.3.8 to 7.4.0

Also update:

  • wagtail-factories 4.1 > 4.4
  • wagtail-honeypot 1.2 > 1.3
  • wagtail-inventory 3.1 > 3.3

Part of https://github.com/freedomofpress/fpf-www-projects/issues/508

Notes from work done by @SaptakS
Changes proposed in this pull request:

  • Enabled deferred validation to support autosaves by adding null=True wherever makes sense. I have left out some of the orderables since they do seem risky. Adding null=True does remove the db level contraint, though Wagtail itself makes the separation such that null=True is used for deciding drafts, whereas blank=True is used to determine whether the field is actually optional.
  • Sets WAGTAILSNIPPETS_MENU_SHOW_ALL to True so that all the snippets are shown in the "Snippets" menu in admin.

Type of change

  • Bug fix
  • New feature
  • Vulnerabilities update
  • Config changes
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires an admin update after deploy
  • Includes a database migration removing or renaming a field

Testing

Full QA of site.

@paulschreiber
Copy link
Copy Markdown
Contributor Author

This test is failing:

======================================================================
FAIL: test_serialize_general_and_category_fields (incident.tests.test_get_serialized_filters.GetSerializedFiltersTest.test_serialize_general_and_category_fields)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/django/incident/tests/test_get_serialized_filters.py", line 190, in test_serialize_general_and_category_fields
    with self.assertNumQueries(7):
AssertionError: 6 != 7 : 6 queries executed, 7 expected

@SaptakS
Copy link
Copy Markdown
Contributor

SaptakS commented May 11, 2026

There are few different errors and failures that I am trying to fix before making it ready for review.

One of the errors is caused due to the change in handling of OPTIONS request Wagtail since 6.4. Using hooks, the OPTIONS response is served separately, and actually never reaches our RoutablePageMixin view that implements the additional headers. The get and head methods still work like before. We can either update the test to use head() if we only care about testing the headers. But if we care about testing and allowing OPTIONS method, then maybe need to override that hook or something.

cc-ing @chigby since he might have some thoughts and ideas.

@SaptakS
Copy link
Copy Markdown
Contributor

SaptakS commented May 11, 2026

For the Site does not exist errors, it weirdly only happens when all the tests are run, and not when the individual test suites are run. I am trying to look into it to figure out what might be the cause since I don't really see anything in the changelog that should be causing this. Especially since it only happens when all the tests are run together and not individually.

I feel like this is happening due to cache pollution or something where the default site gets deleted in between which is why it only happens when the entire test suite is run. The error is happening in the WagtailMetadataMixin where it is trying to get the default site white is somehow already deleted (or site_id is changed somewhere in cache). So I am considering just creating the Site in the setUpTestData everytime so that the MetadataMixin can always find the default site during testing. Unless someone else has some better ideas.

@SaptakS SaptakS marked this pull request as ready for review May 14, 2026 13:14
@SaptakS SaptakS requested review from a team as code owners May 14, 2026 13:14
@willbarton willbarton self-assigned this May 14, 2026
paulschreiber and others added 8 commits May 18, 2026 18:33
- update wagtail from 6.3.8 to 7.4
- update wagtail-factories from 4.1 to 4.4
- update wagtail-honeypot from 1.2 to 1.3
- update wagtail-inventory from 3.1 to 3.3
Wagtail 7.0 introduces [deferred validation](https://docs.wagtail.org/en/stable/releases/7.0.html#deferring-validation-on-saving-drafts) that validates only on publish (or submit or schedule) and requires that non-text fields [add `null=True`](https://docs.wagtail.org/en/stable/releases/7.0.html#configuring-deferred-validation-of-required-fields) to support that on new draft pages. With Wagtail 7.3 and its autosave, this becomes more immediately user-facing.
In Wagtail 7.x, Snippets menu in admin doesn't show the snippets which
are added in the menu separately. Setting the above settingsto true
shows all snippets in the menu to keep the same behaviour as before.
Two test failures surfaced after the Wagtail 7.4 upgrade:

1. Site.DoesNotExist during template rendering in many tests. The
   `MetadataPageMixin` now calls `self.get_site()` while rendering meta
   tags, which resolves the site id via Wagtail's in-process site root
   paths cache. Test classes that delete the home page (cascading to
   Site) and create a new one in `setUpTestData` populate that cache
   with the new Site's id. The class-teardown rollback removes the new
   Site from the DB but does not fire the signals that would clear the
   cache, so subsequent tests resolve page URLs against a Site id that
   no longer exists. Fix: clear the cache after every test in the
   project's test runner.

2. test_OPTIONS failure on the incident export endpoint. Wagtail 7.4
   added a `before_serve_page` hook that intercepts OPTIONS requests
   before they reach RoutablePageMixin routes, so the custom
   `export_view_OPTIONS` no longer runs. Override
   `handle_options_request` on IncidentIndexPage to attach the CORS
   headers the test (and clients) expect.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@SaptakS
Copy link
Copy Markdown
Contributor

SaptakS commented May 18, 2026

@willbarton I have rebased the PR. Let me know if there is anything else that we should do before merging.

@willbarton
Copy link
Copy Markdown
Contributor

@SaptakS nope, I think it's good!

@SaptakS SaptakS merged commit 79042d2 into develop May 18, 2026
74 of 81 checks passed
@SaptakS SaptakS deleted the fix/wagtail74 branch May 18, 2026 18:17
@github-actions github-actions Bot mentioned this pull request May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade to Wagtail 7.4 LTS

4 participants