Skip to content

Instantly share code, notes, and snippets.

@NotSqrt
Forked from nealtodd/settings_test_snippet.py
Last active July 25, 2026 16:15
Show Gist options
  • Select an option

  • Save NotSqrt/5f3c76cd15e40ef62d09 to your computer and use it in GitHub Desktop.

Select an option

Save NotSqrt/5f3c76cd15e40ef62d09 to your computer and use it in GitHub Desktop.
Another shot at this problem ..
class DisableMigrations(object):
def __contains__(self, item):
return True
def __getitem__(self, item):
return "notmigrations"
MIGRATION_MODULES = DisableMigrations()
@tclancy

tclancy commented Oct 27, 2017

Copy link
Copy Markdown

Looks like you need to alter this slightly on Django 1.11:

def __getitem__(self, item):
        return None

@Jelle28

Jelle28 commented Jul 26, 2018

Copy link
Copy Markdown

Thanks, it still works 👍

@hmzeh

hmzeh commented Jan 11, 2020

Copy link
Copy Markdown

Hello,
Any help please
after running :- ./manage.py test --settings groundup.settings_test
Got this Error :- ModuleNotFoundError: No module named 'notmigrations'

Thanks

@mariuccio

mariuccio commented Jan 30, 2020

Copy link
Copy Markdown

If your Django version is >= 1.9

class DisableMigrations(object):
    def __contains__(self, item):
        return True

    def __getitem__(self, item):
        return None


MIGRATION_MODULES = DisableMigrations()

@bkane11

bkane11 commented Feb 4, 2021

Copy link
Copy Markdown

Awesome, thanks for this

@davidkell

davidkell commented Jul 26, 2021

Copy link
Copy Markdown

This is available in Django 3.1 onwards as a setting https://docs.djangoproject.com/en/3.1/ref/settings/#migrate

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