Migrating data to Postgres from Mysql with Django - how do I migrate generic table data, not model specific?

  1. python manage.py dumpdata modelName > file.json.
  2. created an empty database for a user meder on postgres
  3. modified pga_hb.conf so that meder can use the database
  4. changed the settings in settings.py
  5. python manage.py syncdb ( I didnt create a su )
  6. attempting to loaddata file.json but it complains that the superuser isn't there or doesn't match up...

    Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "/srv/python-environments/saltycrane/lib/python2.5/site-packages/django/core/management/init.py", line 438, in execute_manager utility.execute() File "/srv/python-environments/saltycrane/lib/python2.5/site-packages/django/core/management/init.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/srv/python-environments/saltycrane/lib/python2.5/site-packages/django/core/management/base.py", line 191, in run_from_argv self.execute(*args, **options.dict) File "/srv/python-environments/saltycrane/lib/python2.5/site-packages/django/core/management/base.py", line 220, in execute output = self.handle(*args, **options) File "/srv/python-environments/saltycrane/lib/python2.5/site-packages/django/core/management/commands/loaddata.py", line 219, in handle transaction.commit(using=using) File "/srv/python-environments/saltycrane/lib/python2.5/site-packages/django/db/transaction.py", line 199, in commit connection._commit() File "/srv/python-environments/saltycrane/lib/python2.5/site-packages/django/db/backends/init.py", line 32, in _commit return self.connection.commit() psycopg2.IntegrityError: insert or update on table "bugs_bug" violates foreign key constraint "poster_id_refs_id_89e0243f" DETAIL: Key (poster_id)=(1) is not present in table "auth_user".

Was I not supposed to syncdb? Was I supposed to dumpdata for the generic tables? I still have the db all intact in MySQL but would appreciate any direction.

SIDENOTE: I do have south installed. I did the --initial command a couple days ago. Perhaps I could use south as well?


ANSWERS:


You have to run:

python manage.py dumpdata > file.json.

This will dump data from all tables(Models).

Running python manage.py dumpdata myapp.modelName > file.json. will only dump data for model modelName in app myapp.

You can also try, this if you only want to dump data for model modelName:

python manage.py dumpdata auth myapp.MyModel > file.json

This way data with Users will also dumped.


Use

python manage.py dumpdata --natural > file.json.

More here:


long time ago after excruciating export/import jsons pains I end up using



 MORE:


 ? Migrating data to Postgres from Mysql with Django - how do I migrate generic table data, not model specific?
 ? How do I migrate my current site's users table ( mysql+md5 passwords ) to my new django postgres setup?
 ? django: data migrate permissions
 ? Django default data throw an error during migration
 ? Backwards migration with Django South
 ? Backwards migration with Django South
 ? Backwards migration with Django South
 ? South: how to revert migrations in production server?
 ? Django migrate broken, won't forget a deleted column
 ? Django south migration - Adding FULLTEXT indexes