Skip to content

Instantly share code, notes, and snippets.

@FavorMylikes
Forked from NotSqrt/settings_test_snippet.py
Created December 13, 2017 19:43
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 FavorMylikes/1ea67551005555b6eef2202be0e6be9b to your computer and use it in GitHub Desktop.
Save FavorMylikes/1ea67551005555b6eef2202be0e6be9b to your computer and use it in GitHub Desktop.
Another shot at this problem ..
class DisableMigrations(dict):
def __contains__(self, item):
return True
def __getitem__(self, item):
return None
DATABASES = DisableMigrations()
MIGRATION_MODULES = DisableMigrations()
@FavorMylikes
Copy link
Author

Migrations for django 1.10 has two part,please look at load_disk and recorder

The part of load_disk is for migrations of app model
And the part of recorder for database connection
For the version before 1.9 we need set MIGRATION_MODULES={'do.not.migrate':'notmigrations'} when you are running test
Now we need set it None like MIGRATION_MODULES={'do.not.migrate':None}
So if we do not want make migrations for any app, just subclass a dict and return None for getitem function , and do the same of DATABASES, that is the right thing you need

PS: For command, you need to specify --setting=module.path.settings_test_snippet after test
PPS If you are working at pycharm ,do not set --settings options at Run/Debug configurations, just add path of settings_test_snippet.py at Custom setting. That just be fine!!

enjoy

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