简体   繁体   中英

How to force to use new database when run python manage.py test in Django?

When I type

python manage.py test

Sometimes I get asked if I want to delete the test database.

Type 'yes' if you would like to try deleting the test database 'test_replicate_live', or 'no' to cancel: yes

WHen I want to keep the test database, I know the command is :

python manage.py test --keepdb

I would like to know if there's a way to force the deletion of test database without waiting for the question to appear.

Sometimes I just know ahead of time, I want to delete the test database.

Is tehre a

python manage.py test --nokeepdb

You could try

python manage.py test --noinput

Which would suppress the prompt and default to destroying the test database.

It's documented here, https://docs.djangoproject.com/en/2.2/topics/testing/overview/#the-test-database

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM