-
-
Save c-rhodes/cebe9d4619125949dff8 to your computer and use it in GitHub Desktop.
A solution to avoid migrations when testing in Django 1.7, the config is set in manage.py so no environment variables have to be set
This file contains hidden or 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
# settings.py | |
class DisableMigrations(object): | |
def __contains__(self, item): | |
return True | |
def __getitem__(self, item): | |
return "notmigrations" | |
# This would be a subclass of a settings class, in my case Local, i.e. class UnitTests(Local): | |
class UnitTests: | |
MIGRATION_MODULES = DisableMigrations() | |
# Add this to manage.py | |
if 'test' in sys.argv: | |
os.environ['DJANGO_CONFIGURATION'] = 'UnitTests' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment