Skip to content

Commit 9bffd35

Browse files
Handle bytestrings in JSON. Closes #4185. (#4191)
1 parent bb22ab8 commit 9bffd35

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

rest_framework/utils/encoders.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def default(self, obj):
5151
return six.text_type(obj)
5252
elif isinstance(obj, QuerySet):
5353
return tuple(obj)
54+
elif isinstance(obj, six.binary_type):
55+
# Best-effort for binary blobs. See #4187.
56+
return obj.decode('utf-8')
5457
elif hasattr(obj, 'tolist'):
5558
# Numpy arrays and array scalars.
5659
return obj.tolist()

0 commit comments

Comments
 (0)