diff options
| author | Tom Christie | 2013-09-13 11:42:15 -0700 |
|---|---|---|
| committer | Tom Christie | 2013-09-13 11:42:15 -0700 |
| commit | 36bd4f22a7018f0d4780d1148f71539e24d4e6e3 (patch) | |
| tree | f8f9ea7bf70aae8977e5f008b5ca430427b4e42a /rest_framework/utils/encoders.py | |
| parent | d75ecb3d69d01849685864341c89d59e6a3121cd (diff) | |
| parent | d489c5c88144a25ef0d61fb8deb0b77f3a061480 (diff) | |
| download | django-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.py | 2 |
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) |
