Explorar o código

Annotate rack search queryset with device count

kkthxbye %!s(int64=4) %!d(string=hai) anos
pai
achega
a84ae88214
Modificáronse 1 ficheiros con 3 adicións e 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',