From 0f85c97038a3d2e8588733d0d70a4bac5e96c5e6 Mon Sep 17 00:00:00 2001 From: Victor Golovanenko Date: Mon, 26 Apr 2021 08:40:06 +0000 Subject: [PATCH] Optimization: do not create an additional request to get interfaces --- netbox_interface_sync/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox_interface_sync/views.py b/netbox_interface_sync/views.py index 1424e3a..ad90bcb 100644 --- a/netbox_interface_sync/views.py +++ b/netbox_interface_sync/views.py @@ -17,7 +17,7 @@ class InterfaceComparisonView(LoginRequiredMixin, PermissionRequiredMixin, View) def get(self, request, device_id): device = get_object_or_404(Device.objects.filter(id=device_id)) - interfaces = Interface.objects.filter(device=device) + interfaces = device.vc_interfaces if config["exclude_virtual_interfaces"]: interfaces = list(filter(lambda i: not i.is_virtual, interfaces)) interface_templates = InterfaceTemplate.objects.filter(device_type=device.device_type) @@ -58,7 +58,7 @@ class InterfaceComparisonView(LoginRequiredMixin, PermissionRequiredMixin, View) form = InterfaceComparisonForm(request.POST) if form.is_valid(): device = get_object_or_404(Device.objects.filter(id=device_id)) - interfaces = Interface.objects.filter(device=device) + interfaces = device.vc_interfaces if config["exclude_virtual_interfaces"]: interfaces = interfaces.exclude(type__in=["virtual", "lag"]) interface_templates = InterfaceTemplate.objects.filter(device_type=device.device_type)