aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/utils/encoders.py
diff options
context:
space:
mode:
authorTom Christie2013-09-13 11:42:15 -0700
committerTom Christie2013-09-13 11:42:15 -0700
commit36bd4f22a7018f0d4780d1148f71539e24d4e6e3 (patch)
treef8f9ea7bf70aae8977e5f008b5ca430427b4e42a /rest_framework/utils/encoders.py
parentd75ecb3d69d01849685864341c89d59e6a3121cd (diff)
parentd489c5c88144a25ef0d61fb8deb0b77f3a061480 (diff)
downloaddjango-rest-framework-36bd4f22a7018f0d4780d1148f71539e24d4e6e3.tar.bz2
Merge pull request #1107 from dpretty/master
Let JSONEncoder handle Numpy data types.
Diffstat (limited to 'rest_framework/utils/encoders.py')
-rw-r--r--rest_framework/utils/encoders.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/rest_framework/utils/encoders.py b/rest_framework/utils/encoders.py
index b26a2085..7efd5417 100644
--- a/rest_framework/utils/encoders.py
+++ b/rest_framework/utils/encoders.py
@@ -42,6 +42,8 @@ class JSONEncoder(json.JSONEncoder):
return str(o.total_seconds())
elif isinstance(o, decimal.Decimal):
return str(o)
+ elif hasattr(o, 'tolist'):
+ return o.tolist()
elif hasattr(o, '__iter__'):
return [i for i in o]
return super(JSONEncoder, self).default(o)