diff options
| author | Tom Christie | 2014-10-09 08:31:46 +0100 |
|---|---|---|
| committer | Tom Christie | 2014-10-09 08:31:46 +0100 |
| commit | 87fdc73f64ed955b10450d9c16b615edfd94a879 (patch) | |
| tree | aa13a8d44f72287d5977d0f6d559625f73c8079d | |
| parent | f7d43f530a94e686d2f93781471b9ac4e90d0f58 (diff) | |
| parent | 79e91dff92443ab1f301638ac280bd3231a2ca15 (diff) | |
| download | django-rest-framework-87fdc73f64ed955b10450d9c16b615edfd94a879.tar.bz2 | |
Merge pull request #1920 from thedrow/topic/encoder-improvements
The JSON encoder now uses tuples instead of lists
| -rw-r--r-- | rest_framework/utils/encoders.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/rest_framework/utils/encoders.py b/rest_framework/utils/encoders.py index 7c4179a1..486186c9 100644 --- a/rest_framework/utils/encoders.py +++ b/rest_framework/utils/encoders.py @@ -45,7 +45,7 @@ class JSONEncoder(json.JSONEncoder): # Serializers will coerce decimals to strings by default. return float(obj) elif isinstance(obj, QuerySet): - return list(obj) + return tuple(obj) elif hasattr(obj, 'tolist'): # Numpy arrays and array scalars. return obj.tolist() @@ -55,7 +55,7 @@ class JSONEncoder(json.JSONEncoder): except: pass elif hasattr(obj, '__iter__'): - return [item for item in obj] + return tuple(item for item in obj) return super(JSONEncoder, self).default(obj) |
