本文整理汇总了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 []