1
0
mirror of https://github.com/django/django.git synced 2025-10-25 06:36:07 +00:00

Added support for serializing BinaryField

This commit is contained in:
Claude Paroz
2012-12-15 00:26:08 +01:00
parent 8ee1eddb7e
commit d680a3f447
4 changed files with 34 additions and 8 deletions

View File

@@ -142,6 +142,8 @@ def force_bytes(s, encoding='utf-8', strings_only=False, errors='strict'):
If strings_only is True, don't convert (some) non-string-like objects.
"""
if isinstance(s, six.memoryview):
s = bytes(s)
if isinstance(s, bytes):
if encoding == 'utf-8':
return s