0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 17:36:49 +01:00

Allow disabling search auto-update on a per-model basis (#4946)

This commit is contained in:
Karl Hobley 2018-12-07 11:00:30 +00:00 committed by Matt Westcott
parent 8c4b3fe669
commit 50e72dc58b
4 changed files with 20 additions and 0 deletions

View File

@ -6,6 +6,7 @@ Changelog
* Added support for customising EditHandler-based forms on a per-request basis (Bertrand Bordage)
* Added more informative error message when `|richtext` filter is applied to a non-string value (mukesh5)
* Automatic search indexing can now be disabled on a per-model basis via the `search_auto_update` attribute (Karl Hobley)
* Fix: Set `SERVER_PORT` to 443 in `Page.dummy_request()` for HTTPS sites (Sergey Fedoseev)
* Fix: Include port number in `Host` header of `Page.dummy_request()` (Sergey Fedoseev)
* Fix: Validation error messages in `InlinePanel` no longer count towards `max_num` when disabling the 'add' button (Todd Dembrey, Thibaud Colas)

View File

@ -16,6 +16,7 @@ Other features
* Added support for customising EditHandler-based forms on a per-request basis (Bertrand Bordage)
* Added more informative error message when ``|richtext`` filter is applied to a non-string value (mukesh5)
* Automatic search indexing can now be disabled on a per-model basis via the ``search_auto_update`` attribute (Karl Hobley)
Bug fixes

View File

@ -26,6 +26,21 @@ Signal handlers
``wagtailsearch`` provides some signal handlers which bind to the save/delete signals of all indexed models. This would automatically add and delete them from all backends you have registered in ``WAGTAILSEARCH_BACKENDS``. These signal handlers are automatically registered when the ``wagtail.search`` app is loaded.
In some cases, you may not want your content to be automatically reindexed and instead rely on the ``update_index`` command for indexing. If you need to disable these signal handlers, use one of the following methods:
Disabling auto update signal handlers for a model
`````````````````````````````````````````````````
You can disable the signal handlers for an individual model by adding ``search_auto_update = False`` as an attribute on the model class.
Disabling auto update signal handlers for a search backend/whole site
`````````````````````````````````````````````````````````````````````
You can disable the signal handlers for a whole search backend by setting the ``AUTO_UPDATE`` setting on the backend to ``False``.
If all search backends have ``AUTO_UPDATE`` set to ``False``, the signal handlers will be completely disabled for the whole site.
For documentation on the ``AUTO_UPDATE`` setting, see :ref:`wagtailsearch_backends_auto_update`.
The ``update_index`` command
----------------------------

View File

@ -20,5 +20,8 @@ def post_delete_signal_handler(instance, **kwargs):
def register_signal_handlers():
# Loop through list and register signal handlers for each one
for model in index.get_indexed_models():
if getattr(model, 'search_auto_update', True) == False:
continue
post_save.connect(post_save_signal_handler, sender=model)
post_delete.connect(post_delete_signal_handler, sender=model)