diff --git a/geotrek/api/v2/views/outdoor.py b/geotrek/api/v2/views/outdoor.py index 37bd380c5f..0ce360926a 100644 --- a/geotrek/api/v2/views/outdoor.py +++ b/geotrek/api/v2/views/outdoor.py @@ -23,10 +23,12 @@ def get_queryset(self): activate(self.request.GET.get('language')) return outdoor_models.Site.objects \ .annotate(geom_transformed=Transform(F('geom'), settings.API_SRID)) \ + .select_related('parent', 'practice', 'type') \ .prefetch_related(Prefetch('attachments', queryset=Attachment.objects.select_related('license', 'filetype', 'filetype__structure')), Prefetch('view_points', - queryset=HDViewPoint.objects.select_related('content_type', 'license').annotate(geom_transformed=Transform(F('geom'), settings.API_SRID)))) \ + queryset=HDViewPoint.objects.select_related('content_type', 'license').annotate(geom_transformed=Transform(F('geom'), settings.API_SRID))), + 'information_desks', 'labels', 'managers', 'pois_excluded', 'portal', 'ratings', 'source', 'themes', 'web_links') \ .order_by('name') # Required for reliable pagination @@ -93,6 +95,10 @@ def get_queryset(self): activate(self.request.GET.get('language')) return outdoor_models.Course.objects \ .annotate(geom_transformed=Transform(F('geom'), settings.API_SRID)) \ + .select_related('type') \ .prefetch_related(Prefetch('attachments', - queryset=Attachment.objects.select_related('license', 'filetype', 'filetype__structure'))) \ + queryset=Attachment.objects.select_related('license', 'filetype', 'filetype__structure')), + Prefetch('course_children', queryset=outdoor_models.OrderedCourseChild.objects.select_related('parent', 'child')), + Prefetch('course_parents', queryset=outdoor_models.OrderedCourseChild.objects.select_related('parent', 'child')), + 'parent_sites', 'pois_excluded', 'ratings') \ .order_by('name') # Required for reliable pagination