diff --git a/geotrek/api/v2/views/outdoor.py b/geotrek/api/v2/views/outdoor.py index 37bd380c5f..05f3c9a8ce 100644 --- a/geotrek/api/v2/views/outdoor.py +++ b/geotrek/api/v2/views/outdoor.py @@ -26,7 +26,8 @@ def get_queryset(self): .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))), + 'parent') \ .order_by('name') # Required for reliable pagination @@ -94,5 +95,8 @@ def get_queryset(self): return outdoor_models.Course.objects \ .annotate(geom_transformed=Transform(F('geom'), settings.API_SRID)) \ .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') \ .order_by('name') # Required for reliable pagination