Python django.db.models.signals.post_migrate.connect() Examples

The following are 30 code examples of django.db.models.signals.post_migrate.connect(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.db.models.signals.post_migrate , or try the search function .
Example #1
Source File: management.py    From django-taxii-services with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 
Example #2
Source File: apps.py    From django-admin-view-permission with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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) 
Example #3
Source File: test_signals.py    From django-test-migrations with MIT License 6 votes vote down vote up
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,
        ) 
Example #4
Source File: apps.py    From trunk-player with MIT License 5 votes vote down vote up
def ready(self):
        post_migrate.connect(default_data_setup, sender=self)
        import_module("radio.receivers") 
Example #5
Source File: test_indexable.py    From django-elasticsearch with MIT License 5 votes vote down vote up
def setUp(self):
        from django.db.models.signals import post_save, post_delete
        try:
            from django.db.models.signals import post_migrate
        except ImportError:  # django <= 1.6
            from django.db.models.signals import post_syncdb as post_migrate

        from django_elasticsearch.models import es_save_callback
        from django_elasticsearch.models import es_delete_callback
        from django_elasticsearch.models import es_syncdb_callback
        try:
            from django.apps import apps
            app = apps.get_app_config('django_elasticsearch')
        except ImportError: # django 1.4
            from django.db.models import get_app
            app = get_app('django_elasticsearch')

        post_save.connect(es_save_callback)
        post_delete.connect(es_delete_callback)
        post_migrate.connect(es_syncdb_callback)
        
        if int(get_version()[2]) >= 6:
            sender = app
        else:
            sender = None
        post_migrate.send(sender=sender,
                          app_config=app,
                          app=app,  # django 1.4
                          created_models=[TestModel,],
                          verbosity=2)

        self.instance = TestModel.objects.create(username=u"1",
                                                 first_name=u"woot",
                                                 last_name=u"foo")
        self.instance.es.do_index() 
Example #6
Source File: apps.py    From django-admin-interface with MIT License 5 votes vote down vote up
def ready(self):

        from admin_interface import settings
        from admin_interface.models import Theme

        settings.check_installed_apps()
        post_migrate.connect(
            Theme.post_migrate_handler, sender=self) 
Example #7
Source File: apps.py    From openhgsenti with Apache License 2.0 5 votes vote down vote up
def ready(self):
        post_migrate.connect(create_permissions,
            dispatch_uid="django.contrib.auth.management.create_permissions")
        checks.register(check_user_model, checks.Tags.models) 
Example #8
Source File: apps.py    From openhgsenti with Apache License 2.0 5 votes vote down vote up
def ready(self):
        post_migrate.connect(update_contenttypes)
        checks.register(check_generic_foreign_keys, checks.Tags.models) 
Example #9
Source File: apps.py    From openhgsenti with Apache License 2.0 5 votes vote down vote up
def ready(self):
        post_migrate.connect(create_default_site, sender=self) 
Example #10
Source File: apps.py    From python2017 with MIT License 5 votes vote down vote up
def ready(self):
        post_migrate.connect(
            create_permissions,
            dispatch_uid="django.contrib.auth.management.create_permissions"
        )
        checks.register(check_user_model, checks.Tags.models)
        checks.register(check_models_permissions, checks.Tags.models) 
Example #11
Source File: apps.py    From PonyConf with Apache License 2.0 5 votes vote down vote up
def ready(self):
        import cfp.signals  # noqa
        post_migrate.connect(cfp.signals.call_first_site_post_save, sender=self) 
Example #12
Source File: apps.py    From promgen with MIT License 5 votes vote down vote up
def ready(self):
        from promgen import signals, checks  # NOQA

        post_migrate.connect(default_shard, sender=self)
        post_migrate.connect(default_admin, sender=self) 
Example #13
Source File: apps.py    From cleanerversion with Apache License 2.0 5 votes vote down vote up
def ready(self):
        """
        For postgresql only, remove like indexes for uuid columns and
        create version-unique indexes.

        This will only be run in django >= 1.7.

        :return: None
        """
        if connection.vendor == 'postgresql':
            post_migrate.connect(index_adjustments, sender=self) 
Example #14
Source File: apps.py    From product-definition-center with MIT License 5 votes vote down vote up
def ready(self, *args, **kwargs):
        from . import signals
        post_migrate.connect(signals.update_resources, sender=self) 
Example #15
Source File: apps.py    From colossus with MIT License 5 votes vote down vote up
def ready(self):
        post_migrate.connect(create_default_template, sender=self) 
Example #16
Source File: apps.py    From Kiwi with GNU General Public License v2.0 5 votes vote down vote up
def ready(self):
        from .models import Bug
        from .management import create_permissions
        from tcms import signals

        post_save.connect(signals.handle_emails_post_bug_save, sender=Bug)
        post_migrate.connect(
            create_permissions,
            dispatch_uid="tcms.bugs.management.create_permissions"
        ) 
Example #17
Source File: apps.py    From ideascube with GNU Affero General Public License v3.0 5 votes vote down vote up
def ready(self):
        pre_migrate.connect(create_index, sender=self)
        post_migrate.connect(reindex, sender=self) 
Example #18
Source File: apps.py    From Hands-On-Application-Development-with-PyCharm with MIT License 5 votes vote down vote up
def ready(self):
        post_migrate.connect(
            create_permissions,
            dispatch_uid="django.contrib.auth.management.create_permissions"
        )
        last_login_field = getattr(get_user_model(), 'last_login', None)
        # Register the handler only if UserModel.last_login is a field.
        if isinstance(last_login_field, DeferredAttribute):
            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) 
Example #19
Source File: app.py    From tfrs with Apache License 2.0 5 votes vote down vote up
def ready(self):
        """Django callback when application is loaded"""

        # register our interest in the post_migrate signal
        post_migrate.connect(post_migration_callback, sender=self)

        if RUNSERVER:
            try:
                check_external_services()
            except RuntimeError as error:
                print('Startup checks failed. Not starting.')
                print(error)
                exit(-1)  # Django doesn't seem to do this automatically. 
Example #20
Source File: apps.py    From django-ra-erp with GNU Affero General Public License v3.0 5 votes vote down vote up
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"
        ) 
Example #21
Source File: apps.py    From django-ra-erp with GNU Affero General Public License v3.0 5 votes vote down vote up
def ready(self):
        from ra.utils.permissions import create_report_permissions
        super().ready()
        post_migrate.connect(
            create_report_permissions, sender=self) 
Example #22
Source File: apps.py    From zulip with Apache License 2.0 5 votes vote down vote up
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) 
Example #23
Source File: apps.py    From tramcar with MIT License 5 votes vote down vote up
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) 
Example #24
Source File: apps.py    From thirtylol with MIT License 5 votes vote down vote up
def ready(self):
        post_migrate.connect(init_db, sender=self) 
Example #25
Source File: apps.py    From thirtylol with MIT License 5 votes vote down vote up
def ready(self):
        post_migrate.connect(init_db, sender=self) 
Example #26
Source File: apps.py    From aiohttp-json-rpc with Apache License 2.0 5 votes vote down vote up
def ready(self):
        post_migrate.connect(
            lambda sender, **kwargs: generate_view_permissions(),
            sender=self,
            weak=False,
        ) 
Example #27
Source File: apps.py    From bioforum with MIT License 5 votes vote down vote up
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) 
Example #28
Source File: monkey_patch.py    From django-cachalot with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def patch():
    post_migrate.connect(_invalidate_on_migration)

    _patch_cursor()
    _patch_atomic()
    _patch_orm() 
Example #29
Source File: apps.py    From GTDWeb with GNU General Public License v2.0 5 votes vote down vote up
def ready(self):
        post_migrate.connect(create_default_site, sender=self) 
Example #30
Source File: apps.py    From GTDWeb with GNU General Public License v2.0 5 votes vote down vote up
def ready(self):
        post_migrate.connect(update_contenttypes)
        checks.register(check_generic_foreign_keys, checks.Tags.models)