本文整理匯總了Python中django.db.router.allow_migrate方法的典型用法代碼示例。如果您正苦於以下問題:Python router.allow_migrate方法的具體用法?Python router.allow_migrate怎麽用?Python router.allow_migrate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.db.router
的用法示例。
在下文中一共展示了router.allow_migrate方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: database_forwards
# 需要導入模塊: from django.db import router [as 別名]
# 或者: from django.db.router import allow_migrate [as 別名]
def database_forwards(self, app_label, schema_editor, from_state, to_state):
if router.allow_migrate(schema_editor.connection.alias, app_label, **self.hints):
self._run_sql(schema_editor, self.sql)
示例2: database_backwards
# 需要導入模塊: from django.db import router [as 別名]
# 或者: from django.db.router import allow_migrate [as 別名]
def database_backwards(self, app_label, schema_editor, from_state, to_state):
if self.reverse_sql is None:
raise NotImplementedError("You cannot reverse this operation")
if router.allow_migrate(schema_editor.connection.alias, app_label, **self.hints):
self._run_sql(schema_editor, self.reverse_sql)
示例3: _check_backend_specific_checks
# 需要導入模塊: from django.db import router [as 別名]
# 或者: from django.db.router import allow_migrate [as 別名]
def _check_backend_specific_checks(self, **kwargs):
app_label = self.model._meta.app_label
for db in connections:
if router.allow_migrate(db, app_label, model_name=self.model._meta.model_name):
return connections[db].validation.check_field(self, **kwargs)
return []
示例4: _check_backend_specific_checks
# 需要導入模塊: from django.db import router [as 別名]
# 或者: from django.db.router import allow_migrate [as 別名]
def _check_backend_specific_checks(self, **kwargs):
app_label = self.model._meta.app_label
for db in connections:
if router.allow_migrate(db, app_label, model=self.model):
return connections[db].validation.check_field(self, **kwargs)
return []