diff --git a/apps/collection/models.py b/apps/collection/models.py index 0457f38d..8024effb 100644 --- a/apps/collection/models.py +++ b/apps/collection/models.py @@ -57,6 +57,10 @@ class CollectionQuerySet(RelatedObjectsCountMixin): """Returned only published collection""" return self.filter(is_publish=True) + def with_base_related(self): + """Select relate objects""" + return self.select_related('country') + class Collection(ProjectBaseMixin, CollectionDateMixin, TranslatedFieldsMixin, URLImageMixin): diff --git a/apps/collection/views/back.py b/apps/collection/views/back.py index 481f70da..032bafb3 100644 --- a/apps/collection/views/back.py +++ b/apps/collection/views/back.py @@ -75,7 +75,7 @@ class CollectionBackOfficeViewSet(mixins.CreateModelMixin, """ViewSet for Collection model for BackOffice users.""" permission_classes = (permissions.IsAuthenticated,) - queryset = models.Collection.objects.all() + queryset = models.Collection.objects.with_base_related() filter_backends = [DjangoFilterBackend, OrderingFilter] serializer_class = serializers.CollectionBackOfficeSerializer bind_object_serializer_class = serializers.CollectionBindObjectSerializer