Python django.conf.settings.MIGRATION_MODULES Examples

The following are 8 code examples for showing how to use django.conf.settings.MIGRATION_MODULES(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module django.conf.settings , or try the search function .

Example 1
Project: GTDWeb   Author: lanbing510   File: loader.py    License: 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
Project: bioforum   Author: reBiocoder   File: loader.py    License: 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
Project: django-test-without-migrations   Author: henriquebastos   File: _base.py    License: 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
Project: Hands-On-Application-Development-with-PyCharm   Author: PacktPublishing   File: loader.py    License: 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
Project: python   Author: Yeah-Kun   File: loader.py    License: 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
Project: openhgsenti   Author: drexly   File: loader.py    License: 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
Project: python2017   Author: bpgc-cte   File: loader.py    License: 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
Project: django-leonardo   Author: django-leonardo   File: pull_migrations.py    License: 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])