Opened 14 years ago
Closed 12 years ago
#16317 closed Bug (fixed)
Self-referencing model with natural key: dumpdata can't resolve dependencies
Reported by: | Simon Meers | Owned by: | nobody |
---|---|---|---|
Component: | Core (Serialization) | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | s.federici@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I have a self-referencing model with a natural key, but dumpdata won't serialize it:
Error: Can't resolve dependencies for app_label.ModelName in serialized app list
This is probably perfectly valid if use_natural_keys=True, but shouldn't I be able to serialize it without natural keys? I suspect dumpdata.sort_dependencies should take the flag setting into consideration before throwing natural-key-based dependencies into the mix?
Attachments (2)
Change History (13)
comment:1 by , 14 years ago
comment:2 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 13 years ago
Has patch: | set |
---|
The patch is valid for ForeignKey, ManyToMany and OneToYne Fields
I've added a simple test case.
There is another problem related to this issue, in order to load "self related objects" by natural keys using get_by_natural_key()
is obvious think that the related instances are already in the database.
The Serializator needs to serialize in a intelligent order (but if there are cycle dependency it is impossible) or by serializing the objects with no relations and after another serialization with them. I don't want open another issue for that, actually I think it is possible by writing the fixtures by hand.
comment:4 by , 13 years ago
Cc: | added |
---|
comment:6 by , 13 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
I've update the patch, for the new release 17765, the content is not changed.
comment:7 by , 13 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Ready for checkin → Accepted |
The updated patch seems to be missing the dumpdata.py part.
comment:8 by , 13 years ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
follow-up: 10 comment:9 by , 13 years ago
Yes thanks, you're right.
in the previous upload the dumpdata.py part was missing
now I've update the patch for the new release 17766
comment:10 by , 13 years ago
what happened to this patch? I've just caught this bug and found out it was issued here
comment:11 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
(the intention is to serialise the self-referencing model separately natural keys, but use the natural key functionality in references from other models)