diff --git a/netbox_floorplan/views.py b/netbox_floorplan/views.py index 32bd6ab..901c025 100644 --- a/netbox_floorplan/views.py +++ b/netbox_floorplan/views.py @@ -116,8 +116,9 @@ def get(self, request): self.queryset = Rack.objects.all().filter(~Q(id__in=fp_instance.mapped_racks)).filter( site=fp_instance.site.id).order_by("name") else: + locations = Location.objects.get(pk=fp_instance.location.id).get_descendants(include_self=True) self.queryset = Rack.objects.all().filter(~Q(id__in=fp_instance.mapped_racks)).filter( - location=fp_instance.location.id).order_by("name") + location__in=locations).order_by("name") return super().get(request) @@ -132,6 +133,7 @@ def get(self, request): self.queryset = Device.objects.all().filter(~Q(id__in=fp_instance.mapped_devices)).filter( site=fp_instance.site.id, rack=None).order_by("name") else: + locations = Location.objects.get(pk=fp_instance.location.id).get_descendants(include_self=True) self.queryset = Device.objects.all().filter(~Q(id__in=fp_instance.mapped_devices)).filter( location=fp_instance.location.id, rack=None).order_by("name") return super().get(request)