diff options
| author | Tom Christie | 2015-01-19 15:16:57 +0000 | 
|---|---|---|
| committer | Tom Christie | 2015-01-19 15:16:57 +0000 | 
| commit | 6065cdbd939542dec79708615bc3e75b38834f41 (patch) | |
| tree | b7e582185f1383d630dfe7b1fb8dc1e504599164 /rest_framework/utils | |
| parent | 4f3c3a06cfc0ea2dfbf46da2d98546664343ce93 (diff) | |
| parent | fdeef89ba79e617ea22dae68a0b42b3f60d67a4d (diff) | |
| download | django-rest-framework-6065cdbd939542dec79708615bc3e75b38834f41.tar.bz2 | |
Merge master
Diffstat (limited to 'rest_framework/utils')
| -rw-r--r-- | rest_framework/utils/encoders.py | 6 | ||||
| -rw-r--r-- | rest_framework/utils/serializer_helpers.py | 6 | 
2 files changed, 11 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'): diff --git a/rest_framework/utils/serializer_helpers.py b/rest_framework/utils/serializer_helpers.py index 65a04d06..f9960603 100644 --- a/rest_framework/utils/serializer_helpers.py +++ b/rest_framework/utils/serializer_helpers.py @@ -16,6 +16,9 @@ class ReturnDict(OrderedDict):      def copy(self):          return ReturnDict(self, serializer=self.serializer) +    def __repr__(self): +        return dict.__repr__(self) +  class ReturnList(list):      """ @@ -27,6 +30,9 @@ class ReturnList(list):          self.serializer = kwargs.pop('serializer')          super(ReturnList, self).__init__(*args, **kwargs) +    def __repr__(self): +        return list.__repr__(self) +  class BoundField(object):      """ | 
