mirror of
https://github.com/netbox-community/netbox.git
synced 2026-03-21 20:18:38 -06:00
* Fixes #21402: Prefetch device_type and manufacturer for brief mode API responses Add select_related for device_type__manufacturer on the DeviceViewSet queryset to prevent N+1 queries when rendering unnamed devices in brief mode. * Use prefetch_related instead of select_related for device_type__manufacturer
This commit is contained in:
@@ -405,6 +405,7 @@ class DeviceViewSet(
|
||||
NetBoxModelViewSet
|
||||
):
|
||||
queryset = Device.objects.prefetch_related(
|
||||
'device_type__manufacturer', # Referenced by Device.__str__() for unnamed devices
|
||||
'parent_bay', # Referenced by DeviceSerializer.get_parent_device()
|
||||
)
|
||||
filterset_class = filtersets.DeviceFilterSet
|
||||
|
||||
Reference in New Issue
Block a user