0

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?

Gagan Singh
  • 200
  • 1
  • 13

2 Answers2

1

If you are in django>=1.11 try remove stale content types before exporting backup

python manage.py remove_stale_contenttypes
Enrico Ferreguti
  • 438
  • 4
  • 13
0

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

abtinmo
  • 336
  • 2
  • 11