當前位置: 首頁>>代碼示例>>Python>>正文


Python settings.MIGRATION_MODULES屬性代碼示例

本文整理匯總了Python中django.conf.settings.MIGRATION_MODULES屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.MIGRATION_MODULES屬性的具體用法?Python settings.MIGRATION_MODULES怎麽用?Python settings.MIGRATION_MODULES使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在django.conf.settings的用法示例。


在下文中一共展示了settings.MIGRATION_MODULES屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: migrations_module

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import MIGRATION_MODULES [as 別名]
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) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:8,代碼來源:loader.py

示例2: migrations_module

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import MIGRATION_MODULES [as 別名]
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 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:13,代碼來源:loader.py

示例3: handle

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import MIGRATION_MODULES [as 別名]
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) 
開發者ID:henriquebastos,項目名稱:django-test-without-migrations,代碼行數:11,代碼來源:_base.py

示例4: handle

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import MIGRATION_MODULES [as 別名]
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]) 
開發者ID:django-leonardo,項目名稱:django-leonardo,代碼行數:47,代碼來源:pull_migrations.py


注:本文中的django.conf.settings.MIGRATION_MODULES屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。