Opened 17 years ago

Closed 17 years ago

#6726 closed (invalid)

python manage.py dumpdata doesn't sort objects in correct order

Reported by: leotr Owned by: nobody
Component: Core (Other) Version: dev
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

Description

I have to manually reorder objects in initial_data.<xml, json> before i run python manage.py loaddata.
I think that firstly python manage.py 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 by Russell Keith-Magee, 17 years ago

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.

http://www.djangoproject.com/documentation/django-admin/#loaddata-fixture-fixture

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