Python django.conf.settings.MIGRATION_MODULES Examples

The following are 8 code examples of django.conf.settings.MIGRATION_MODULES(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.conf.settings , or try the search function .
Example #1
Source File: loader.py    From GTDWeb with GNU General Public License v2.0 5 votes vote down vote up
def migrations_module(cls, app_label):
        if app_label in settings.MIGRATION_MODULES:
            return settings.MIGRATION_MODULES[app_label]
        else:
            app_package_name = apps.get_app_config(app_label).name
            return '%s.%s' % (app_package_name, MIGRATIONS_MODULE_NAME) 
Example #2
Source File: loader.py    From bioforum with MIT License 5 votes vote down vote up
def migrations_module(cls, app_label):
        """
        Return the path to the migrations module for the specified app_label
        and a boolean indicating if the module is specified in
        settings.MIGRATION_MODULE.
        """
        if app_label in settings.MIGRATION_MODULES:
            return settings.MIGRATION_MODULES[app_label], True
        else:
            app_package_name = apps.get_app_config(app_label).name
            return '%s.%s' % (app_package_name, MIGRATIONS_MODULE_NAME), False 
Example #3
Source File: _base.py    From django-test-without-migrations with MIT License 5 votes vote down vote up
def handle(self, *test_labels, **options):
        for arg in ('-n', '--nomigrations'):
            if arg in sys.argv:
                sys.argv.remove(arg)

        if options['nomigrations']:
            settings.MIGRATION_MODULES = DisableMigrations()

        super(CommandMixin, self).handle(*test_labels, **options) 
Example #4
Source File: loader.py    From Hands-On-Application-Development-with-PyCharm with MIT License 5 votes vote down vote up
def migrations_module(cls, app_label):
        """
        Return the path to the migrations module for the specified app_label
        and a boolean indicating if the module is specified in
        settings.MIGRATION_MODULE.
        """
        if app_label in settings.MIGRATION_MODULES:
            return settings.MIGRATION_MODULES[app_label], True
        else:
            app_package_name = apps.get_app_config(app_label).name
            return '%s.%s' % (app_package_name, MIGRATIONS_MODULE_NAME), False 
Example #5
Source File: loader.py    From python with Apache License 2.0 5 votes vote down vote up
def migrations_module(cls, app_label):
        """
        Return the path to the migrations module for the specified app_label
        and a boolean indicating if the module is specified in
        settings.MIGRATION_MODULE.
        """
        if app_label in settings.MIGRATION_MODULES:
            return settings.MIGRATION_MODULES[app_label], True
        else:
            app_package_name = apps.get_app_config(app_label).name
            return '%s.%s' % (app_package_name, MIGRATIONS_MODULE_NAME), False 
Example #6
Source File: loader.py    From openhgsenti with Apache License 2.0 5 votes vote down vote up
def migrations_module(cls, app_label):
        if app_label in settings.MIGRATION_MODULES:
            return settings.MIGRATION_MODULES[app_label]
        else:
            app_package_name = apps.get_app_config(app_label).name
            return '%s.%s' % (app_package_name, MIGRATIONS_MODULE_NAME) 
Example #7
Source File: loader.py    From python2017 with MIT License 5 votes vote down vote up
def migrations_module(cls, app_label):
        """
        Return the path to the migrations module for the specified app_label
        and a boolean indicating if the module is specified in
        settings.MIGRATION_MODULE.
        """
        if app_label in settings.MIGRATION_MODULES:
            return settings.MIGRATION_MODULES[app_label], True
        else:
            app_package_name = apps.get_app_config(app_label).name
            return '%s.%s' % (app_package_name, MIGRATIONS_MODULE_NAME), False 
Example #8
Source File: pull_migrations.py    From django-leonardo with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def handle(self, *args, **options):

        skipped_paths = []
        pull_apps = []

        if len(args) > 0:
            app_names = args[0]
            if not isinstance(app_names, list):
                app_names = app_names.split(',')

                _apps = []
                for app_name in app_names:
                    try:
                        app = apps.get_app_config(app_name)
                    except:
                        skipped_paths(app_name)
                    else:
                        _apps.append(app.path)
        else:
            for app in apps.get_app_configs():
                for migration_name in settings.MIGRATION_MODULES.keys():
                    if app.name == migration_name:
                        if app not in pull_apps:
                            pull_apps.append(app)

        def copytree(src, dst, symlinks=False, ignore=None):
            for item in os.listdir(src):
                s = os.path.join(src, item)
                d = os.path.join(dst, item)
                if os.path.isdir(s):
                    shutil.copytree(s, d, symlinks, ignore)
                else:
                    shutil.copy2(s, d)

        for app in pull_apps:
            module_name = settings.MIGRATION_MODULES[app.name]
            migration_path = import_module(module_name).__path__[0]

            self.stdout.write("Copy %s to %s" % (app.path, migration_path))

            if os.path.exists(os.path.join(app.path, 'migrations')):
                copytree(os.path.join(app.path, 'migrations'), migration_path)

        self.stdout.write('Successfully pulled %s' % [app.name
                                                      for app in pull_apps])