mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-25 00:36:11 -06:00
Avoid calling remove() on non-cacheable objects
This commit is contained in:
parent
19c6f95f62
commit
5c1463a77d
@ -87,6 +87,11 @@ class SearchBackend:
|
|||||||
"""
|
"""
|
||||||
Receiver for the post_delete signal, responsible for caching object deletion.
|
Receiver for the post_delete signal, responsible for caching object deletion.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
|
get_indexer(instance)
|
||||||
|
except KeyError:
|
||||||
|
# Avoid attempting to query for non-cacheable objects
|
||||||
|
return
|
||||||
cls.remove(instance)
|
cls.remove(instance)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -193,7 +198,7 @@ class CachedValueSearchBackend(SearchBackend):
|
|||||||
ct = ContentType.objects.get_for_model(instance)
|
ct = ContentType.objects.get_for_model(instance)
|
||||||
|
|
||||||
# Wipe out any previously cached values for the object
|
# Wipe out any previously cached values for the object
|
||||||
CachedValue.objects.filter(object_type=ct, object_id=instance.pk).delete()
|
cls.remove(instance)
|
||||||
|
|
||||||
# Record any new non-empty values
|
# Record any new non-empty values
|
||||||
cached_values = []
|
cached_values = []
|
||||||
|
Loading…
Reference in New Issue
Block a user