#24320 closed Bug (fixed)
Unable to serialize UUIDField when running dumpdata with JSON format
Reported by: | James Beith | Owned by: | Andriy Sokolovskiy |
---|---|---|---|
Component: | Core (Serialization) | Version: | 1.8alpha1 |
Severity: | Release blocker | Keywords: | |
Cc: | me@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
A model using a UUIDField as its primary key. Running dumpdata
management command with JSON output format (the default option) resulted in the following error
CommandError: Unable to serialize database: UUID('435697b4-954a-4b9a-a83a-2b53016b0d43') is not JSON serializable
However running again with --format=xml
did not result in an error and dumpdata
was successful.
Attachments (3)
Change History (17)
comment:1 Changed 7 years ago by
Description: | modified (diff) |
---|---|
Summary: | Unable to serialize UUID field when running dumpdata with JSON format → Unable to serialize UUIDField when running dumpdata with JSON format |
comment:2 Changed 7 years ago by
Component: | Utilities → Core (Serialization) |
---|---|
Severity: | Normal → Release blocker |
Triage Stage: | Unreviewed → Accepted |
comment:3 Changed 7 years ago by
Changed 7 years ago by
Attachment: | 24320-test.diff added |
---|
comment:6 Changed 7 years ago by
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
Please reopen with more details if this is still an issue.
comment:7 Changed 7 years ago by
Resolution: | needsinfo |
---|---|
Status: | closed → new |
I have created an example project which reproduces the issue.
comment:8 Changed 7 years ago by
Thanks. Problem seems to be having a FK to an object with a UUID pk. Attaching a failing test for Django's test suite.
Changed 7 years ago by
Attachment: | 24320-test.2.diff added |
---|
comment:9 Changed 7 years ago by
Owner: | changed from nobody to Andriy Sokolovskiy |
---|---|
Status: | new → assigned |
I will try to fix this
comment:10 Changed 7 years ago by
Cc: | me@… added |
---|---|
Has patch: | set |
comment:11 Changed 7 years ago by
comment:12 Changed 7 years ago by
Opened new PR to master:
https://github.com/django/django/pull/4125
comment:13 Changed 7 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I created a custom user with UUID pk:
And then tried:
Tested on SQLite and PostgreSQL. Could you provide more details? I'm also attached a test for Django's test suite that I tried writing to reproduce the issue.