Last active
April 13, 2017 04:19
-
-
Save wolever/8948bc29ca08a693dd9aca9bce187077 to your computer and use it in GitHub Desktop.
Prevent Django from asking if you're sure you'd like to delete your test database.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Add this function to your app's __init__.py (or similar) to prevent Django | |
from ever asking if you're sure you'd like to delete your test database. | |
""" | |
def _patch_django_create_test_db(): | |
from django.db.backends.base.creation import BaseDatabaseCreation | |
old_create_test_db = BaseDatabaseCreation._create_test_db | |
def _create_test_db(self, verbosity, autoclobber, *args, **kwargs): | |
return old_create_test_db(self, verbosity, True, *args, **kwargs) | |
BaseDatabaseCreation._create_test_db = _create_test_db | |
_patch_django_create_test_db() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes!