From 47a69b0e5bbb851c15461884dedfcb4753117243 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 17 Jun 2020 12:20:56 -0400 Subject: [PATCH] DummyQuerySet should be iterable to allow for serialization --- netbox/extras/middleware.py | 2 +- netbox/utilities/querysets.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/netbox/extras/middleware.py b/netbox/extras/middleware.py index 6abd28bf6..c8be8755f 100644 --- a/netbox/extras/middleware.py +++ b/netbox/extras/middleware.py @@ -46,7 +46,7 @@ def handle_deleted_object(sender, instance, **kwargs): # Preserve tags if is_taggable(instance): - copy.tags = list(instance.tags.all()) + copy.tags = DummyQuerySet(instance.tags.all()) # Queue the copy of the object for processing once the request completes _thread_locals.changed_objects.append( diff --git a/netbox/utilities/querysets.py b/netbox/utilities/querysets.py index 1ac79e90a..ff7c69a89 100644 --- a/netbox/utilities/querysets.py +++ b/netbox/utilities/querysets.py @@ -10,6 +10,9 @@ class DummyQuerySet: def __init__(self, queryset): self._cache = [obj for obj in queryset.all()] + def __iter__(self): + return iter(self._cache) + def all(self): return self._cache