Ver Fonte

Tweak queryset for Service views to prefetch related IPs with unrestricted()

Jeremy Stretch há 5 anos atrás
pai
commit
9f025747a7
1 ficheiros alterados com 6 adições e 2 exclusões
  1. 6 2
      netbox/ipam/views.py

+ 6 - 2
netbox/ipam/views.py

@@ -809,7 +809,9 @@ class ServiceListView(ObjectListView):
 
 
 class ServiceView(ObjectView):
-    queryset = Service.objects.all()
+    queryset = Service.objects.prefetch_related(
+        Prefetch('ipaddresses', IPAddress.objects.unrestricted())
+    )
 
     def get(self, request, pk):
 
@@ -821,7 +823,9 @@ class ServiceView(ObjectView):
 
 
 class ServiceEditView(ObjectEditView):
-    queryset = Service.objects.all()
+    queryset = Service.objects.prefetch_related(
+        Prefetch('ipaddresses', IPAddress.objects.unrestricted())
+    )
     model_form = forms.ServiceForm
     template_name = 'ipam/service_edit.html'