kogbla
Last Updated: February 25, 2016
·
8.604K
· gamebit07

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
Say Thanks
Respond

2 Responses
Add your response

17335
None

your post helped me :) thanks!

over 1 year ago ·
26822
over 1 year ago ·