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


Python exceptions.MigrationSchemaMissing方法代碼示例

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


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

示例1: check_migrations

# 需要導入模塊: from django.db.migrations import exceptions [as 別名]
# 或者: from django.db.migrations.exceptions import MigrationSchemaMissing [as 別名]
def check_migrations(self):
        """
        Checks to see if the set of migrations on disk matches the
        migrations in the database. Prints a warning if they don't match.
        """
        try:
            executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
        except ImproperlyConfigured:
            # No databases are configured (or the dummy one)
            return
        except MigrationSchemaMissing:
            self.stdout.write(self.style.NOTICE(
                "\nNot checking migrations as it is not possible to access/create the django_migrations table."
            ))
            return

        plan = executor.migration_plan(executor.loader.graph.leaf_nodes())
        if plan:
            self.stdout.write(self.style.NOTICE(
                "\nYou have unapplied migrations; your app may not work properly until they are applied."
            ))
            self.stdout.write(self.style.NOTICE("Run 'python manage.py migrate' to apply them.\n"))

# Kept for backward compatibility 
開發者ID:wanzifa,項目名稱:wanblog,代碼行數:26,代碼來源:runserver.py

示例2: check_migrations

# 需要導入模塊: from django.db.migrations import exceptions [as 別名]
# 或者: from django.db.migrations.exceptions import MigrationSchemaMissing [as 別名]
def check_migrations(self):
        """
        Print a warning if the set of migrations on disk don't match the
        migrations in the database.
        """
        from django.db.migrations.executor import MigrationExecutor
        try:
            executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
        except ImproperlyConfigured:
            # No databases are configured (or the dummy one)
            return
        except MigrationSchemaMissing:
            self.stdout.write(self.style.NOTICE(
                "\nNot checking migrations as it is not possible to access/create the django_migrations table."
            ))
            return

        plan = executor.migration_plan(executor.loader.graph.leaf_nodes())
        if plan:
            apps_waiting_migration = sorted(set(migration.app_label for migration, backwards in plan))
            self.stdout.write(
                self.style.NOTICE(
                    "\nYou have %(unpplied_migration_count)s unapplied migration(s). "
                    "Your project may not work properly until you apply the "
                    "migrations for app(s): %(apps_waiting_migration)s." % {
                        "unpplied_migration_count": len(plan),
                        "apps_waiting_migration": ", ".join(apps_waiting_migration),
                    }
                )
            )
            self.stdout.write(self.style.NOTICE("Run 'python manage.py migrate' to apply them.\n")) 
開發者ID:KimJangHyeon,項目名稱:NarshaTech,代碼行數:33,代碼來源:base.py


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