Oct 17, 2025 · by Tim Kamanin
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 could still use the old import. Therefore, the version 7 upgrade led to the above error.
Luckily, the solution is simple (as with most things involving Wagtail ❤️). We fix it in three quick steps:
wagtail.contrib.search_promotions app to INSTALLED_APPSINSTALLED_APPS = [
# ...
"wagtail.contrib.search_promotions",
]
# Old
from wagtail.search.models import Query
# New
from wagtail.contrib.search_promotions.models import Query
python manage.py migrate
And that’s it - Query now lives under wagtail.contrib.search_promotions, and your project should load normally again.
Hey, if you've found this useful, please share the post to help other folks find it: