Last Updated: February 25, 2016
· gamebit07

Django fixture dumpdata, loaddata and Integrity Error

To dump fixtures in django you do this -

python 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 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 dumpdata --exclude=contenttypes --exclude=auth.Permission > initial_data.json

2 Responses
Add your response

your post helped me :) thanks!

over 1 year ago ·