Django fixture dumpdata, loaddata and Integrity Error
To dump fixtures in django you do this -
python manage.py dumpdata > initial_data.json
Having done this if you want to load this data on a fresh database, you will do it this way -
python manage.py loaddata initial_data.json
you will get Integrityerror for contenttypes, auth, groups and admin.
IntegrityError: Problem installing fixture 'shipping_fixture.json': Could not load contenttypes.ContentType(pk=2)
An easy way out -
python manage.py dumpdata --exclude=contenttypes --exclude=auth.Permission > initial_data.json
Written by Skate Hunbash
Related protips
2 Responses
your post helped me :) thanks!
over 1 year ago
·
Hi tried your solution but no luck can you please help me with this http://stackoverflow.com/questions/35539241/getting-django-db-utils-integrityerror-when-migrating-data-from-sqlite-to-postgr
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#