Reputation: 230
I created a backup of database using fixtures in my django project by following command:-
python manage.py dumpdata > db.json
when i load the fixture, i get following error:-
django.db.utils.IntegrityError: Problem installing fixture '/home/gagan/saporawebapp/webapp/fixtures/db.json': Could not load contenttypes.ContentType(pk=17): duplicate key value violates unique constraint "django_content_type_app_label_model_76bd3d3b_uniq"
DETAIL: Key (app_label, model)=(webapp, homescreen) already exists. I don't know how integrity erros arises even when i'm just loading the fixture. How can i solve this error? Edit I figured it out because i forget to exclude auth.permission and contenttypes while dumping my database but i still do not know how to rectify it?
Upvotes: 0
Views: 585
Reputation: 508
If you are in django>=1.11 try remove stale content types before exporting backup
python manage.py remove_stale_contenttypes
Upvotes: 1
Reputation: 366
your content-type table in your db has a record with duplicate app_label, and different pk, app_label is unique and you can't insert new value with existing app_label
Upvotes: 0