aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/utils/encoders.py
diff options
context:
space:
mode:
authorTom Christie2015-01-19 15:23:08 +0000
committerTom Christie2015-01-19 15:23:08 +0000
commite5b94f7b7bbf2f6f35c5e33fb2723bdb0d33bad3 (patch)
treea156a4a29a26540c52e5580ffa555b14d6c63fbe /rest_framework/utils/encoders.py
parentdbb684117f6fe0f9c34f98d5e914fc106090cdbc (diff)
parent3cc39ffbceffc5fdbb511d9a10e7732329e8baa4 (diff)
downloaddjango-rest-framework-e5b94f7b7bbf2f6f35c5e33fb2723bdb0d33bad3.tar.bz2
Merge branch 'version-3.1' into cursor-pagination
Diffstat (limited to 'rest_framework/utils/encoders.py')
-rw-r--r--rest_framework/utils/encoders.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/rest_framework/utils/encoders.py b/rest_framework/utils/encoders.py
index 0bd24939..2160d18b 100644
--- a/rest_framework/utils/encoders.py
+++ b/rest_framework/utils/encoders.py
@@ -6,9 +6,11 @@ from django.db.models.query import QuerySet
from django.utils import six, timezone
from django.utils.encoding import force_text
from django.utils.functional import Promise
+from rest_framework.compat import total_seconds
import datetime
import decimal
import json
+import uuid
class JSONEncoder(json.JSONEncoder):
@@ -38,10 +40,12 @@ class JSONEncoder(json.JSONEncoder):
representation = representation[:12]
return representation
elif isinstance(obj, datetime.timedelta):
- return six.text_type(obj.total_seconds())
+ return six.text_type(total_seconds(obj))
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'):