Answer the question
In order to leave comments, you need to log in
Why can't I start django testserver with fixtures?
I'm trying to run tests on a production base. Did the following:
./manage.py dumpdata --natural > dump.json
django-admin testserver dump.json
django.db.utils.IntegrityError: Problem installing fixture '/home/zuber/Projects/PCR/project/apps/bn/fixtures/real_db.json': Could not load contenttypes.ContentType(pk=1): UNIQUE constraint failed: django_content_type.app_label, django_content_type.model
Answer the question
In order to leave comments, you need to log in
When running tests, the database is not created completely empty, because Django does a few extra steps after running syncdb or migrate (in newer versions), such as calling the update_contenttypes method , which populates the ContentTypes table.
There are several options for solving the problem, but I suggest dumping the data with this line:
Thus, you will exclude data from the fixture, which is already created automatically every time the tests are run.
For further reading I recommend stackoverflow.com/questions/853796/problems-with-c...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question