Reputation: 1259
Have deleted my database.
Have run SyncDb.
Trying to load from dump ..-python manage.py loaddata dump.json.
Get- "<1062 Duplicate entry '' for key.."
Have run "python manage.py reset contentypes"
But get-
Error: Error: contenttypes couldn't be reset. Possible reasons:
* The database isn't running or isn't configured correctly.
* At least one of the database tables doesn't exist.
* The SQL was invalid.
Hint: Look at the output of 'django-admin.py sqlreset contenttypes'. That's the SQL this command wasn't able to run.
The full error: (1217, 'Cannot delete or update a parent row: a foreign key constraint fails')
Have try to run:
from django.core import management
management.call_command("flush", verbosity=, interactive=False)
management.call_command("totally reset", "contenttypes", verbosity=, interactive=False)
management.call_command("loaddata", "full_test_data.json", verbosity=)
But get- syntax error.
Have python 2.7. and Django 1.4
Any ideas?
Upvotes: 1
Views: 731
Reputation: 22439
Try setting foreign_key_checks
false,
DATABASES = {
'default': {
# ...
'OPTIONS': {
"init_command": "SET foreign_key_checks = 0;",
},
}
}
But you should definitely try to use the dumpdata command with the --natural option to make sure there's no hardcoded content types in your fixtures.
Upvotes: 1