Prefetch: change the type of value prefetch accept.

It's 'auto' by default, but can be changed to 'medium' and soon
another value.
This commit is contained in:
Tom Hacohen
2020-08-04 17:44:57 +03:00
parent a613a32628
commit cf9b6f5904
2 changed files with 3 additions and 3 deletions

View File

@@ -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: