Integrity error when loading fixtures for Selenium testing in Django Integrity error when loading fixtures for Selenium testing in Django selenium selenium

Integrity error when loading fixtures for Selenium testing in Django


After some more reading about how Django maintains its own models and such, it is my understanding that Django caches the contenttype, auth.Permission, etc and uses them in testing frameworks (I was using StaticLiveServerTestCase). This means that when I was loading my fixture, it was clashing with the data Django had stored for its own uses causing the integrity error. This is what worked for me:

python manage.py dumpdata -e contenttypes -e admin -e auth.Permission --natural-foreign --indent=2 > functional_tests/fixtures/initial_data4.json

This post has some additional helpful information to help me solve the problem:Problems with contenttypes when loading a fixture in Django.