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 Version 1
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 (last modified by )
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
Change History (1)
comment:1 by , 9 years ago
Description: | modified (diff) |
---|---|
Type: | Uncategorized → New feature |
Note:
See TracTickets
for help on using tickets.
The proposed code looks rather complicated. What you are saying is that the instructions about fixture ordering aren't sufficient due to the possibility of circular references, correct? Could you give an example of that to motivate the feature a bit more?