diff --git a/django_etebase/serializers.py b/django_etebase/serializers.py index 8cfddad..40f6068 100644 --- a/django_etebase/serializers.py +++ b/django_etebase/serializers.py @@ -109,7 +109,7 @@ class UserSlugRelatedField(serializers.SlugRelatedField): class ChunksField(serializers.RelatedField): def to_representation(self, obj): obj = obj.chunk - if self.context.get('prefetch'): + if self.context.get('prefetch') == 'auto': with open(obj.chunkFile.path, 'rb') as f: return (obj.uid, f.read()) else: diff --git a/django_etebase/views.py b/django_etebase/views.py index 95031e3..9d76d08 100644 --- a/django_etebase/views.py +++ b/django_etebase/views.py @@ -190,7 +190,7 @@ class CollectionViewSet(BaseViewSet): def get_serializer_context(self): context = super().get_serializer_context() - prefetch = self.request.query_params.get('prefetch', 'true') != 'false' + prefetch = self.request.query_params.get('prefetch', 'auto') context.update({'request': self.request, 'prefetch': prefetch}) return context @@ -256,7 +256,7 @@ class CollectionItemViewSet(BaseViewSet): def get_serializer_context(self): context = super().get_serializer_context() - prefetch = self.request.query_params.get('prefetch', 'true') != 'false' + prefetch = self.request.query_params.get('prefetch', 'auto') context.update({'request': self.request, 'prefetch': prefetch}) return context