Просмотр исходного кода

Fixes #7301: Fix exception when deleting a large number of child prefixes

jeremystretch 4 лет назад
Родитель
Сommit
8ba5d03280
2 измененных файлов с 4 добавлено и 3 удалено
  1. 1 0
      docs/release-notes/version-3.0.md
  2. 3 3
      netbox/netbox/views/generic.py

+ 1 - 0
docs/release-notes/version-3.0.md

@@ -25,6 +25,7 @@
 * [#7279](https://github.com/netbox-community/netbox/issues/7279) - Fix exception when tracing cable with no associated path
 * [#7282](https://github.com/netbox-community/netbox/issues/7282) - Fix KeyError exception when `INSECURE_SKIP_TLS_VERIFY` is true
 * [#7298](https://github.com/netbox-community/netbox/issues/7298) - Restore missing object names from applied object list filters
+* [#7301](https://github.com/netbox-community/netbox/issues/7301) - Fix exception when deleting a large number of child prefixes
 
 ---
 

+ 3 - 3
netbox/netbox/views/generic.py

@@ -1010,10 +1010,10 @@ class BulkDeleteView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View):
 
         # Are we deleting *all* objects in the queryset or just a selected subset?
         if request.POST.get('_all'):
+            qs = model.objects.all()
             if self.filterset is not None:
-                pk_list = [obj.pk for obj in self.filterset(request.GET, model.objects.only('pk')).qs]
-            else:
-                pk_list = model.objects.values_list('pk', flat=True)
+                qs = self.filterset(request.GET, qs).qs
+            pk_list = qs.only('pk').values_list('pk', flat=True)
         else:
             pk_list = [int(pk) for pk in request.POST.getlist('pk')]