From b19881779248bd57ff79f92ace059627d008322e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Szulc?= Date: Thu, 31 Oct 2024 14:06:30 +0100 Subject: [PATCH] Fix prefetches --- src/ralph/data_center/admin.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ralph/data_center/admin.py b/src/ralph/data_center/admin.py index f2d72b5e9c..a1691b0979 100644 --- a/src/ralph/data_center/admin.py +++ b/src/ralph/data_center/admin.py @@ -28,6 +28,7 @@ from ralph.admin.mixins import ( BulkEditChangeListMixin, RalphAdmin, + RalphAdminImportExportMixin, RalphTabularInline ) from ralph.admin.views.extra import RalphDetailViewAdmin @@ -490,6 +491,15 @@ class DataCenterAssetAdmin( }), ) + def get_export_queryset(self, request): + # we skip method in RalphAdminImportExportMixin because it doesn't return a queryset + # sad :( + return super(RalphAdminImportExportMixin, self).get_export_queryset(request).select_related( + *self.list_select_related + ).polymorphic_prefetch_related( + DataCenterAsset=['tags', 'ethernet_set__ipaddress', 'parent__ethernet_set__ipaddress'], + ) + def get_multiadd_fields(self, obj=None): multiadd_fields = [ {'field': 'sn', 'allow_duplicates': False},