Reputation: 3
After upgrading to Wagtail 2.15 (or 2.15.1) from 2.14.2 my production website with postgres and database search breaks and commands that are run with manage.py
give an error despite me adding the required WAGTAILSEARCH_BACKENDS
to settings.
I have two web apps with separate settings running from the same Wagtail version. One of the apps (putkeep) has a search bar and the other (secretgifter) does not. After upgrading Wagtail from 2.14.2 to 2.15, putkeep gives a 404 error but secretgifter does not. If I use pip to switch back to 2.14.2, then the 404 error goes away and the site loads (although results from a search give a 500 error).
If I run makemigrations
(or any other command that uses manage.py
) for secretgifter it works fine. For putkeep (with the search) it gives the following error:
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/th-putkeep.net/putkeep/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/home/th-putkeep.net/putkeep/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
django.setup()
File "/home/th-putkeep.net/putkeep/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/th-putkeep.net/putkeep/lib/python3.8/site-packages/django/apps/registry.py", line 122, in populate
app_config.ready()
File "/home/th-putkeep.net/putkeep/lib/python3.8/site-packages/wagtail/search/apps.py", line 21, in ready
set_weights()
File "/home/th-putkeep.net/putkeep/lib/python3.8/site-packages/wagtail/search/backends/database/postgres/weights.py", line 44, in set_weights
BOOSTS_WEIGHTS.extend(determine_boosts_weights())
File "/home/th-putkeep.net/putkeep/lib/python3.8/site-packages/wagtail/search/backends/database/postgres/weights.py", line 32, in determine_boosts_weights
boosts = get_boosts()
File "/home/th-putkeep.net/putkeep/lib/python3.8/site-packages/wagtail/search/backends/database/postgres/weights.py", line 26, in get_boosts
boosts.add(boost)
TypeError: unhashable type: 'list'
As per the docs I've added this to my settings:
WAGTAILSEARCH_BACKENDS = {
'default': {
'BACKEND': 'wagtail.search.backends.database',
}
}
Any suggestions gratefully received.
Upvotes: 0
Views: 138
Reputation: 1296
I think the issue is with your configuration that is trying to search tag names:
index.SearchField('tags', [
index.SearchField('name', partial_match=True, boost=10),
]),
The default database search doesn't appear to offer an option to search related objects this way (See note under https://docs.wagtail.io/en/stable/topics/search/indexing.html#indexing-callables-and-other-attributes). You can either remove those lines or, for the moment, go back to the postgres_search backend in wagtail/contrib.
Upvotes: 0
Reputation: 3
I have identified some code in my models.py
that caused no errors with my site running Wagtail 2.14.2 and below. When commented out, it resolves the error caused by upgrading to Wagtail 2.15 and above. I am posting it here as the answer to my problem because everything else seems to work (including search) without any further modification even though I am not currently sure why it causes the error or if I need it anymore:
search_fields = Page.search_fields + [ # Inherit search_fields from Page
index.SearchField('content'),
index.SearchField('tags', [
index.SearchField('name', partial_match=True, boost=10),
]),
]
Upvotes: 0