diff options
| author | Tom Christie | 2015-01-19 14:18:02 +0000 | 
|---|---|---|
| committer | Tom Christie | 2015-01-19 14:19:01 +0000 | 
| commit | da1db34a36f6f0cb8722acbbf7c3182e32995ae3 (patch) | |
| tree | 858ebe157a9aca8d4100a7ec3bfba48d8b4e709d | |
| parent | b3a0a2794bcaf2ca29244f88a1d9d67ce9850b23 (diff) | |
| download | django-rest-framework-da1db34a36f6f0cb8722acbbf7c3182e32995ae3.tar.bz2 | |
Handle UUID objects in JSONEncoder. Closes #2433.
| -rw-r--r-- | rest_framework/utils/encoders.py | 3 | 
1 files changed, 3 insertions, 0 deletions
| diff --git a/rest_framework/utils/encoders.py b/rest_framework/utils/encoders.py index 104343a4..bf753271 100644 --- a/rest_framework/utils/encoders.py +++ b/rest_framework/utils/encoders.py @@ -12,6 +12,7 @@ import datetime  import decimal  import types  import json +import uuid  class JSONEncoder(json.JSONEncoder): @@ -45,6 +46,8 @@ class JSONEncoder(json.JSONEncoder):          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'): | 
