Skip to content

Commit

Permalink
Fix prefetches
Browse files Browse the repository at this point in the history
  • Loading branch information
hipek8 committed Oct 31, 2024
1 parent d52c3aa commit b198817
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ralph/data_center/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from ralph.admin.mixins import (
BulkEditChangeListMixin,
RalphAdmin,
RalphAdminImportExportMixin,
RalphTabularInline
)
from ralph.admin.views.extra import RalphDetailViewAdmin
Expand Down Expand Up @@ -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},
Expand Down

0 comments on commit b198817

Please sign in to comment.