本文整理汇总了Python中django.db.models.signals.pre_migrate.connect方法的典型用法代码示例。如果您正苦于以下问题:Python pre_migrate.connect方法的具体用法?Python pre_migrate.connect怎么用?Python pre_migrate.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.db.models.signals.pre_migrate
的用法示例。
在下文中一共展示了pre_migrate.connect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ready
# 需要导入模块: from django.db.models.signals import pre_migrate [as 别名]
# 或者: from django.db.models.signals.pre_migrate import connect [as 别名]
def ready(self):
pre_migrate.connect(inject_rename_contenttypes_operations, sender=self)
post_migrate.connect(update_contenttypes)
checks.register(check_generic_foreign_keys, checks.Tags.models)
示例2: ready
# 需要导入模块: from django.db.models.signals import pre_migrate [as 别名]
# 或者: from django.db.models.signals.pre_migrate import connect [as 别名]
def ready(self):
pre_migrate.connect(inject_rename_contenttypes_operations, sender=self)
post_migrate.connect(create_contenttypes)
checks.register(check_generic_foreign_keys, checks.Tags.models)
示例3: ready
# 需要导入模块: from django.db.models.signals import pre_migrate [as 别名]
# 或者: from django.db.models.signals.pre_migrate import connect [as 别名]
def ready(self):
from .operations import inject_pre_migration_operations, inject_post_migration_operations
pre_migrate.connect(inject_pre_migration_operations, sender=self)
post_migrate.connect(inject_post_migration_operations, sender=self)
示例4: ready
# 需要导入模块: from django.db.models.signals import pre_migrate [as 别名]
# 或者: from django.db.models.signals.pre_migrate import connect [as 别名]
def ready(self):
"""
This supports two use cases for using tsvector_field:
1. Configure your Django project to use tsvecotr_field's DatabaseSchemaEditor
directly by creating your own DatabaseWrapper and referencing
tsvector_field.DatabaseSchemaEditor in the SchemaEditorClass attribute.
See: tsvector_field/schema.py for more info.
2. Just add `tsvector_field` to your project's INSTALLED_APPS setting and this
will use the `pre_migrate` mechanism. Note: `pre_migrate` is not fired for
./manage.py migrate --run-syncdb. So if you are building apps without migrations
you will have to use the more reliable approach in option #1.
"""
from django.db import connection
from . import DatabaseSchemaEditor
if not isinstance(connection.schema_editor(), DatabaseSchemaEditor):
# only register for pre_migrate if we're not already configured
# with the DatabaseSchemaEditor, see option #1 in doc above
from django.db.models.signals import pre_migrate
from .receivers import inject_trigger_operations
pre_migrate.connect(inject_trigger_operations)
示例5: ready
# 需要导入模块: from django.db.models.signals import pre_migrate [as 别名]
# 或者: from django.db.models.signals.pre_migrate import connect [as 别名]
def ready(self):
"""
Perform other one-time initialization steps.
"""
from enterprise.signals import handle_user_post_save
from django.db.models.signals import pre_migrate, post_save
post_save.connect(handle_user_post_save, sender=self.auth_user_model, dispatch_uid=USER_POST_SAVE_DISPATCH_UID)
pre_migrate.connect(self._disconnect_user_post_save_for_migrations)