Преглед изворни кода

DummyQuerySet should be iterable to allow for serialization

Jeremy Stretch пре 5 година
родитељ
комит
54ece346bc
2 измењених фајлова са 4 додато и 1 уклоњено
  1. 1 1
      netbox/extras/middleware.py
  2. 3 0
      netbox/utilities/querysets.py

+ 1 - 1
netbox/extras/middleware.py

@@ -46,7 +46,7 @@ def handle_deleted_object(sender, instance, **kwargs):
 
 
     # Preserve tags
     # Preserve tags
     if is_taggable(instance):
     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
     # Queue the copy of the object for processing once the request completes
     _thread_locals.changed_objects.append(
     _thread_locals.changed_objects.append(

+ 3 - 0
netbox/utilities/querysets.py

@@ -10,6 +10,9 @@ class DummyQuerySet:
     def __init__(self, queryset):
     def __init__(self, queryset):
         self._cache = [obj for obj in queryset.all()]
         self._cache = [obj for obj in queryset.all()]
 
 
+    def __iter__(self):
+        return iter(self._cache)
+
     def all(self):
     def all(self):
         return self._cache
         return self._cache