Handle UUID objects in JSONEncoder. Closes #2433.

This commit is contained in:
Tom Christie 2015-01-19 14:18:02 +00:00
parent b3a0a2794b
commit da1db34a36

View File

@ -12,6 +12,7 @@ import datetime
import decimal
import types
import json
import uuid
class JSONEncoder(json.JSONEncoder):
@ -45,6 +46,8 @@ class JSONEncoder(json.JSONEncoder):
elif isinstance(obj, decimal.Decimal):
# Serializers will coerce decimals to strings by default.
return float(obj)
elif isinstance(obj, uuid.UUID):
return six.text_type(obj)
elif isinstance(obj, QuerySet):
return tuple(obj)
elif hasattr(obj, 'tolist'):