Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Test Complaining about Fixture

Dumped data python manage.py dumpdata --format json --indent 4 --exclude auth.permission --exclude contenttypes > app/fixtures/app_test_data.json

Running python manage.py test app, I get the following error:

IntegrityError: Problem installing fixtures: The row in table 'django_admin_log' with       primary key '517' has an invalid foreign key: django_admin_log.content_type_id contains a value '28' that does not have a corresponding value in django_content_type.id.

Any ideas? I've had a lot of similar issues using dumpdata/Django's test-runner.

like image 620
masonjarre Avatar asked Oct 16 '13 23:10

masonjarre


1 Answers

If:

  1. You are just interested in recovering the information from a json you generated before knowing this issue
  2. You don't care about the data of administration logs
  3. You (or someone else) generated the json excluding auth.permission and contenttypes, using a command like: python manage.py dumpdata --exclude auth.permission --exclude contenttypes > db.json

You may recover the information trapped in the json with a text editor, opening the file and deleting the elements associate with the admin.logentry model.

That worked for me!

like image 187
Andres Ramirez Avatar answered Sep 20 '22 21:09

Andres Ramirez