Oct. 21, 2025

Fixing the `Query` import error while upgrading Wagtail from 5 to 7

While upgrading an old project from Wagtail 5 to 7, I encountered this error:

ImportError: cannot import name 'Query' from 'wagtail.search.models'

After some searching, I found out what’s wrong. It turns out Wagtail moved the Query model from wagtail.search.models to wagtail.contrib.search_promotions in version 5, but until version 6, you …

Read now