本文整理汇总了Python中django.db.models.signals.post_migrate.connect方法的典型用法代码示例。如果您正苦于以下问题:Python post_migrate.connect方法的具体用法?Python post_migrate.connect怎么用?Python post_migrate.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.db.models.signals.post_migrate
的用法示例。
在下文中一共展示了post_migrate.connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: retry_handler_registration
# 需要导入模块: from django.db.models.signals import post_migrate [as 别名]
# 或者: from django.db.models.signals.post_migrate import connect [as 别名]
def retry_handler_registration(sender, **kwargs):
"""
Goes through each of the handlers to retry
and retries them w/ retry=False
"""
while len(query_handlers_to_retry):
qh = query_handlers_to_retry.pop()
register_query_handler(qh[0], qh[1], retry=False)
while len(message_handlers_to_retry):
mh = message_handlers_to_retry.pop()
print("retrying", mh[0])
register_message_handler(mh[0], mh[1], retry=False)
# Leaving the sender blank is probably not right, but
# after a few hours digging in django source code i couldn't
# figure out another way to connect this handler so
# it stays this way for now
示例2: ready
# 需要导入模块: from django.db.models.signals import post_migrate [as 别名]
# 或者: from django.db.models.signals.post_migrate import connect [as 别名]
def ready(self):
if django_version() == DjangoVersion.DJANGO_21:
# Disable silently the package for Django => 2.1. We don't override
# admin_site neither the default ModelAdmin.
warnings.warn(
'The package `admin_view_permission is deprecated in '
'Django 2.1. Django added this functionality into the core.',
DeprecationWarning
)
return
if not isinstance(admin.site, AdminViewPermissionAdminSite):
admin.site = AdminViewPermissionAdminSite('admin')
admin.sites.site = admin.site
post_migrate.connect(update_permissions)
示例3: prepare
# 需要导入模块: from django.db.models.signals import post_migrate [as 别名]
# 或者: from django.db.models.signals.post_migrate import connect [as 别名]
def prepare(self):
"""Connect testing ``pre_migrate`` and ``post_migrate`` receivers."""
self.pre_migrate_receiver_mock = mock.MagicMock()
self.post_migrate_receiver_mock = mock.MagicMock()
# ``old_apps`` is not real ``ProjectState`` instance, so we cannot use
# it to get "original" main_app ``AppConfig`` instance needed to
# connect signal receiver, that's the reason we are using
# ``apps`` imported directly from ``django.apps``
self.main_app_config = apps.get_app_config('main_app')
pre_migrate.connect(
self.pre_migrate_receiver_mock,
sender=self.main_app_config,
)
post_migrate.connect(
self.post_migrate_receiver_mock,
sender=self.main_app_config,
)
示例4: ready
# 需要导入模块: from django.db.models.signals import post_migrate [as 别名]
# 或者: from django.db.models.signals.post_migrate import connect [as 别名]
def ready(self):
pre_migrate.connect(create_index, sender=self)
post_migrate.connect(reindex, sender=self)
示例5: ready
# 需要导入模块: from django.db.models.signals import post_migrate [as 别名]
# 或者: from django.db.models.signals.post_migrate import connect [as 别名]
def ready(self):
post_migrate.connect(create_permissions,
dispatch_uid="django.contrib.auth.management.create_permissions")
checks.register(check_user_model, checks.Tags.models)
示例6: ready
# 需要导入模块: from django.db.models.signals import post_migrate [as 别名]
# 或者: from django.db.models.signals.post_migrate import connect [as 别名]
def ready(self):
post_migrate.connect(update_contenttypes)
checks.register(check_generic_foreign_keys, checks.Tags.models)
示例7: ready
# 需要导入模块: from django.db.models.signals import post_migrate [as 别名]
# 或者: from django.db.models.signals.post_migrate import connect [as 别名]
def ready(self):
post_migrate.connect(create_default_site, sender=self)
示例8: patch
# 需要导入模块: from django.db.models.signals import post_migrate [as 别名]
# 或者: from django.db.models.signals.post_migrate import connect [as 别名]
def patch():
post_migrate.connect(_invalidate_on_migration)
_patch_cursor()
_patch_atomic()
_patch_orm()
示例9: ready
# 需要导入模块: from django.db.models.signals import post_migrate [as 别名]
# 或者: from django.db.models.signals.post_migrate import connect [as 别名]
def ready(self):
post_migrate.connect(
create_permissions,
dispatch_uid="django.contrib.auth.management.create_permissions"
)
if hasattr(get_user_model(), 'last_login'):
from .models import update_last_login
user_logged_in.connect(update_last_login, dispatch_uid='update_last_login')
checks.register(check_user_model, checks.Tags.models)
checks.register(check_models_permissions, checks.Tags.models)
示例10: ready
# 需要导入模块: from django.db.models.signals import post_migrate [as 别名]
# 或者: from django.db.models.signals.post_migrate import connect [as 别名]
def ready(self):
post_migrate.connect(
lambda sender, **kwargs: generate_view_permissions(),
sender=self,
weak=False,
)
示例11: ready
# 需要导入模块: from django.db.models.signals import post_migrate [as 别名]
# 或者: from django.db.models.signals.post_migrate import connect [as 别名]
def ready(self):
post_migrate.connect(init_db, sender=self)
示例12: ready
# 需要导入模块: from django.db.models.signals import post_migrate [as 别名]
# 或者: from django.db.models.signals.post_migrate import connect [as 别名]
def ready(self):
from django.contrib.sites.models import Site
from job_board.signals import gen_site_config_post_migrate
from job_board.signals import gen_site_config_post_save
post_save.connect(gen_site_config_post_save, sender=Site)
# NOTE: We list sites before job_board in INSTALLED_APPS, failing to
# do that will result in this post_migrate signal firing before
# the default site has been created.
post_migrate.connect(gen_site_config_post_migrate, sender=self)
示例13: ready
# 需要导入模块: from django.db.models.signals import post_migrate [as 别名]
# 或者: from django.db.models.signals.post_migrate import connect [as 别名]
def ready(self) -> None:
# We import zerver.signals here for the side effect of
# registering the user_logged_in signal receiver. This import
# needs to be here (rather than e.g. at top-of-file) to avoid
# running that code too early in Django's setup process, but
# in any case, this is an intentionally unused import.
import zerver.signals
zerver.signals
if settings.POST_MIGRATION_CACHE_FLUSHING:
post_migrate.connect(flush_cache, sender=self)
示例14: ready
# 需要导入模块: from django.db.models.signals import post_migrate [as 别名]
# 或者: from django.db.models.signals.post_migrate import connect [as 别名]
def ready(self):
from ra.utils.permissions import create_report_permissions
super().ready()
post_migrate.connect(
create_report_permissions, sender=self)
示例15: ready
# 需要导入模块: from django.db.models.signals import post_migrate [as 别名]
# 或者: from django.db.models.signals.post_migrate import connect [as 别名]
def ready(self):
super(RaConfig, self).ready()
from .utils.permissions import create_report_permissions
from . import checks
post_migrate.connect(
create_report_permissions, sender=self,
dispatch_uid="ra.utils.permissions.create_reports_permissions"
)