Opened 9 years ago
Last modified 5 years ago
#26291 closed New feature
loaddata cannot deserialize fixtures with forward references and natural foreign keys — at Initial Version
Reported by: | Peter Inglesby | Owned by: | nobody |
---|---|---|---|
Component: | Core (Serialization) | Version: | 1.9 |
Severity: | Normal | Keywords: | |
Cc: | Russell Keith-Magee, dev@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
The following fixture cannot be deserialized, unless an Author object with name "John Steinbeck" already exists. This is because when Django tries to deserialize the first object, it tries to load an Author with name "John Steinbeck", which fails.
[ { "model": "app.book", "fields": { "title": "East Of Eden", "author": ["John Steinbeck"] } }, { "model": "app.author", "fields": { "name": "John Steinbeck", "date_of_birth": "1902-02-27" } } ]
This problem is avoidable with careful ordering of fixture loading, but is still a problem with fixtures that have circular references.
I have a proposed fix: see PR 6221
Note:
See TracTickets
for help on using tickets.