Opened 11 years ago

Closed 11 years ago

#6726 closed (invalid)

python dumpdata doesn't sort objects in correct order

Reported by: leotr Owned by: nobody
Component: Core (Other) Version: master
Severity: Keywords: loaddata, dumpdata
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I have to manually reorder objects in initial_data.<xml, json> before i run python loaddata.
I think that firstly python dumpdata command should:

  1. dump objects without foreign keys
  2. dump objects having relations to objects in 1.
  3. dump objects having relations to objects in 2.

until all objects are loaded.

Change History (1)

comment:1 Changed 11 years ago by Russell Keith-Magee

Resolution: invalid
Status: newclosed

What you are proposing is impossible in the generic case. As soon as you have cycles in your data, it's impossible to resolve an order that doesn't have forward references.

Luckily, you don't need to reorder the objects in fixtures as long as you use a database backend that has actual support for handling referential integrity. I'm going to take a wild stab in the dark and guess that you're using MySQL with InnoDB tables. The documentation for loaddata mentions why this might be a bad idea.

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