本文整理汇总了Python中south.migration.Migrations.forwards方法的典型用法代码示例。如果您正苦于以下问题:Python Migrations.forwards方法的具体用法?Python Migrations.forwards怎么用?Python Migrations.forwards使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类south.migration.Migrations
的用法示例。
在下文中一共展示了Migrations.forwards方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: skip_migration_if_applied
# 需要导入模块: from south.migration import Migrations [as 别名]
# 或者: from south.migration.Migrations import forwards [as 别名]
def skip_migration_if_applied(settings, app_name, table_name,
name='0001_initial'):
from south.migration import Migrations
import types
migration = Migrations(app_name)[name]
def skip_if_table_exists(original):
def wrapped(self):
# TODO: look into why we're having to return some ridiculous
# lambda
if table_exists(table_name):
return lambda x=None: None
return original()
wrapped.__name__ = original.__name__
return wrapped
migration.forwards = types.MethodType(
skip_if_table_exists(migration.forwards), migration)