Opened 9 years ago

Last modified 9 years ago

#25019 closed Bug

DjangoJSONEncoder does not encode UUIDs — at Version 5

Reported by: lukas-hetzenecker Owned by: nobody
Component: Core (Serialization) Version: 1.8
Severity: Normal Keywords: UUIDField DjangoJSONEncoder
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by James Rivett-Carnac)

Django extends the standard the json encoder from the standard library to enhance its functionality, for example by providing methods to serialize Datetimes and Decimals.

Because UUIDField was included in Django, serialization of uuid.UUID should be possible too.
There are projects out there that make use of UUIDFields and that will run in problems if they try to serialize the model. An example for such a bug report is https://github.com/sehmaschine/django-grappelli/issues/635

Example project is attached.

EDIT

Reopened as Bug with version 1.8 in response to conversation with Russell Keith-Magee in django-developers mailing list.

Change History (6)

by lukas-hetzenecker, 9 years ago

Attachment: example.tar.gz added

comment:1 by lukas-hetzenecker, 9 years ago

Easy pickings: set

comment:2 by Claude Paroz, 9 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Claude Paroz <claude@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 6355a6d:

Fixed #25019 -- Added UUID support in DjangoJSONEncoder

comment:4 by James Rivett-Carnac, 9 years ago

This also impacts the use of UUID fields in other projects, such as django-allauth,

https://github.com/pennersr/django-allauth/issues/916

I believe this fix should also be back ported to the 1.8.x branch because the expected behaviour of 'I serialise my User Model which has a UUID field' into my session or cache crashes.

Cherry picking this commit into the 1.8.x branch fixed all my problems.

comment:5 by James Rivett-Carnac, 9 years ago

Description: modified (diff)
Resolution: fixed
Status: closednew
Type: New featureBug
Version: master1.8
Note: See TracTickets for help on using tickets.
Back to Top