Explorar el Código

Annotate rack search queryset with device count

kkthxbye hace 4 años
padre
commit
a84ae88214
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      netbox/netbox/constants.py

+ 3 - 1
netbox/netbox/constants.py

@@ -65,7 +65,9 @@ DCIM_TYPES = OrderedDict(
             'url': 'dcim:site_list',
         }),
         ('rack', {
-            'queryset': Rack.objects.prefetch_related('site', 'location', 'tenant', 'role'),
+            'queryset': Rack.objects.prefetch_related('site', 'location', 'tenant', 'role').annotate(
+                device_count=count_related(Device, 'rack')
+            ),
             'filterset': RackFilterSet,
             'table': RackTable,
             'url': 'dcim:rack_list',