本文整理匯總了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)