django manage.py loaddata without constraints
I had to quickly inject a dumpdata json file on a mysql server and got this nice message:
IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails
I created a settings file for the loaddata command without mysql foreignkey checks.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
"init_command": "SET foreign_key_checks = 0;",
}
}
}
export DJANGO_SETTINGS_MODULE="project.settings_without_fk_ckecks" python manage.py loaddata data.json
-
jeffpensky reblogged this from djangosaur
-
djangosaur posted this