[Fixed]-Django Python loaddata fails with django.db.utils.IntegrityError

28πŸ‘

βœ…

in your local database you create some ContentType instances.

when you migrate your remote database all ContentType for your models created again.

but when you want to load data you try to load this instances again.

you have 2 solutions

1- remove all content types instances from remote host using django shell

python manage.py shell

>>> from django.contrib.contenttypes.models import ContentType
>>> ContentType.objects.all().delete()

2- remove content type instances from dumped data

python manage.py dumpdata --exclude contenttypes
πŸ‘€vorujack

Leave a comment