Opened 9 years ago

Closed 9 years ago

#25019 closed Bug (fixed)

DjangoJSONEncoder does not encode UUIDs

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.

Attachments (1)

example.tar.gz (2.7 KB ) - added by lukas-hetzenecker 9 years ago.

Download all attachments as: .zip

Change History (9)

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

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

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

In 2e05ef4e:

Added release note for the UUID serialization backport

Refs #25019.

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

Resolution: fixed
Status: newclosed

In ebcfedb0:

[1.8.x] Fixed #25019 -- Added UUID support in DjangoJSONEncoder

Backport of 6355a6d4f5 and 2e05ef4e18 from master.

Note: See TracTickets for help on using tickets.
Back to Top