python manage.py dumpdata modelName > file.json.- created an empty database for a user
mederon postgres - modified pga_hb.conf so that
medercan use the database - changed the settings in
settings.py - python manage.py syncdb ( I didnt create a su )
-
attempting to
loaddata file.jsonbut 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?
You have to run:
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:
This way data with Users will also dumped.