Django cannot clear database during tests

When trying to run my tests (python manage.py test) I get:

CommandError: Database test_db couldn't be flushed. Possible reasons:
  * The database isn't running or isn't configured correctly.
  * At least one of the expected database tables doesn't exist.
  * The SQL was invalid.
Hint: Look at the output of 'django-admin.py sqlflush'. That the SQL this command wasn't able to run.
The full error: cannot truncate a table referenced in a foreign key constraint
DETAIL:  Table "install_location_2015_05_13" references "app".
HINT:  Truncate table "install_location_2015_05_13" at the same time, or use TRUNCATE ... CASCADE.

      

I am using sections in our project that are generated on the fly via a python function (so I can run it periodically). I have no models for these sections.

The partition maintenance function is called after syncdb triggers the post_syncdb signal (which is why it is executed when setting up the test database).

How can I get Django to clear additional tables (sections)? or How can I tell Django to use CASCADE when running tests?

+3


source to share


1 answer


Basically the problem arises when we change the attitude in the M2M field. The old constraint remains and a new constraint is created for the new relationship. Fixed in Django 1.8



0


source







All Articles