Skip to content

Instantly share code, notes, and snippets.

@wolever
Last active April 13, 2017 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolever/8948bc29ca08a693dd9aca9bce187077 to your computer and use it in GitHub Desktop.
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.
"""
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()
@funkaoshi
Copy link

Yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment