diff --git a/src/ralph/admin/mixins.py b/src/ralph/admin/mixins.py index c0496a115a..f359061786 100644 --- a/src/ralph/admin/mixins.py +++ b/src/ralph/admin/mixins.py @@ -421,9 +421,6 @@ def get_export_queryset(self, request): ) if resource_prefetch_related: queryset = queryset.prefetch_related(*resource_prefetch_related) - # cast to list to consider all prefetch_related (django-import-export - # use queryset.iterator() to "save memory", but then for every row - # sql queries are made to fetch all m2m relations) return list(queryset) def get_export_resource_class(self): diff --git a/src/ralph/data_center/admin.py b/src/ralph/data_center/admin.py index 32625631ae..f2d72b5e9c 100644 --- a/src/ralph/data_center/admin.py +++ b/src/ralph/data_center/admin.py @@ -490,13 +490,6 @@ class DataCenterAssetAdmin( }), ) - def get_export_queryset(self, request): - return DataCenterAsset.polymorphic_objects.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}, diff --git a/src/ralph/data_importer/resources.py b/src/ralph/data_importer/resources.py index 6f4faf5671..4e9634fab7 100644 --- a/src/ralph/data_importer/resources.py +++ b/src/ralph/data_importer/resources.py @@ -306,8 +306,16 @@ class DataCenterAssetResource(ResourceWithPrice, RalphModelResource): class Meta: model = physical.DataCenterAsset select_related = ( + 'model__manufacturer', 'model__category', 'service_env__service', 'service_env__environment', 'rack__server_room__data_center', + 'configuration_path', + 'property_of', + 'parent', + 'budget_info', + ) + prefetch_related = ( + 'tags', 'ethernet_set__ipaddress', 'parent__ethernet_set__ipaddress', ) exclude = ('content_type', 'asset_ptr', 'baseobject_ptr', 'connections')