Support 1.8's UUIDField · Issue #2432 · encode/django-rest-framework (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

@tomchristie

Description

@tomchristie

As per comment here: #2426 (comment)

Current str field would result in...

File "/Users/tomjaster/DevFolder/master/airyengine/airy/lib/rest_framework/utils/encoders.py", line 60, in default
    return super(JSONEncoder, self).default(obj)
File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
    TypeError: UUID('335680b8-0f20-4e25-a0e2-3caa052a3e83') is not JSON serializable

We should validate UUID values, and handle str() of them in both the encoder, and in the serializer field.