diff options
Diffstat (limited to 'rest_framework/utils')
| -rw-r--r-- | rest_framework/utils/encoders.py | 3 | ||||
| -rw-r--r-- | rest_framework/utils/mediatypes.py | 2 | 
2 files changed, 4 insertions, 1 deletions
diff --git a/rest_framework/utils/encoders.py b/rest_framework/utils/encoders.py index 229b0b28..c125ac8a 100644 --- a/rest_framework/utils/encoders.py +++ b/rest_framework/utils/encoders.py @@ -3,6 +3,7 @@ Helper classes for parsers.  """  from __future__ import unicode_literals  from django.utils import timezone +from django.db.models.query import QuerySet  from django.utils.datastructures import SortedDict  from django.utils.functional import Promise  from rest_framework.compat import force_text @@ -43,6 +44,8 @@ class JSONEncoder(json.JSONEncoder):              return str(o.total_seconds())          elif isinstance(o, decimal.Decimal):              return str(o) +        elif isinstance(o, QuerySet): +            return list(o)          elif hasattr(o, 'tolist'):              return o.tolist()          elif hasattr(o, '__getitem__'): diff --git a/rest_framework/utils/mediatypes.py b/rest_framework/utils/mediatypes.py index c09c2933..92f99efd 100644 --- a/rest_framework/utils/mediatypes.py +++ b/rest_framework/utils/mediatypes.py @@ -74,7 +74,7 @@ class _MediaType(object):              return 0          elif self.sub_type == '*':              return 1 -        elif not self.params or self.params.keys() == ['q']: +        elif not self.params or list(self.params.keys()) == ['q']:              return 2          return 3  | 
