aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/utils/encoders.py
diff options
context:
space:
mode:
authorTom Christie2015-01-19 12:15:02 +0000
committerTom Christie2015-01-19 12:15:02 +0000
commitb3a0a2794bcaf2ca29244f88a1d9d67ce9850b23 (patch)
treea41483b39be63027acc7be6faac63a39c2c76167 /rest_framework/utils/encoders.py
parent4f27b966a5954c56a96b298198ec93b69583dfad (diff)
parent5484d570cb8214c776273b45320e7d1c73b85a34 (diff)
downloaddjango-rest-framework-b3a0a2794bcaf2ca29244f88a1d9d67ce9850b23.tar.bz2
Merge pull request #2430 from Polyconseil/fbochu/timedelta-json-serialiser-python26-support
Fix timedelta JSON serialization on Python 2.6.
Diffstat (limited to 'rest_framework/utils/encoders.py')
-rw-r--r--rest_framework/utils/encoders.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/rest_framework/utils/encoders.py b/rest_framework/utils/encoders.py
index 73cbe5d8..104343a4 100644
--- a/rest_framework/utils/encoders.py
+++ b/rest_framework/utils/encoders.py
@@ -6,7 +6,7 @@ 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 OrderedDict
+from rest_framework.compat import OrderedDict, total_seconds
from rest_framework.utils.serializer_helpers import ReturnDict, ReturnList
import datetime
import decimal
@@ -41,7 +41,7 @@ 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)