Skip to content

Commit

Permalink
Handle bytestrings in JSON. Closes #4185.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchristie committed Jun 13, 2016
1 parent bb22ab8 commit 5299f32
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rest_framework/utils/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def default(self, obj):
return six.text_type(obj)
elif isinstance(obj, QuerySet):
return tuple(obj)
elif isinstance(obj, six.binary_type):
# Best-effort for binary blobs. See #4187.
return obj.decode('utf-8')
elif hasattr(obj, 'tolist'):
# Numpy arrays and array scalars.
return obj.tolist()
Expand Down

0 comments on commit 5299f32

Please sign in to comment.