Opened 15 years ago

Closed 15 years ago

#7078 closed (duplicate)

dumpdata conflicts with syncdb entries for new installations

Reported by: chazen@… Owned by: nobody
Component: Core (Serialization) Version: dev
Severity: Keywords: dumpdata loaddata syncdb app_label model unique
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 a running django site on a server. I want to copy the server data to a new machine with a new installation, on which I will do testing and development. To do this, I must copy the data in the server's database to the testing machine.

I do the following steps:

  1. On the server:
    python dumpdata > server_live_data.json
  2. On the new testing installation:
    % python syncdb
    You just installed Django's auth system, which means you don't have any superusers defined.
    Would you like to create one now? (yes/no): no
    % python loaddata server_live_data.json
    Installing json fixture 'server_live_data' from absolute path.
    Problem installing fixture 'server_live_data.json': columns app_label, model are not unique

The problem is that the data dumped by "loaddata" includes entries like "auth.permission" and "contenttypes.contenttype". However, these entries are already present in the new database from running "syncdb". The "syncdb" step cannot be skipped, because it creates the empty tables that "loaddata" needs.

One can work around this by manually editing the JSON or XML from dumpdata to remove "contenttypes", "auth", or any other entries added by syncdb. A more robust solution would be an option to loaddata such as "--clobber" to allow it to overwrite data already present in the tables.

(see also this thread: )

Change History (1)

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

Resolution: duplicate
Status: newclosed

Duplicate of #6121.

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