apps.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:morango 作者: learningequality 项目源码 文件源码
def ready(self):
        from django.core.management import call_command
        from morango.models import InstanceIDModel
        from morango.certificates import ScopeDefinition
        from .signals import add_to_deleted_models  # noqa: F401

        # NOTE: Warning: https://docs.djangoproject.com/en/1.10/ref/applications/#django.apps.AppConfig.ready
        # its recommended not to execute queries in this method, but we are producing the same result after the first call, so its OK

        # call this on app load up to get most recent system config settings
        try:
            InstanceIDModel.get_or_create_current_instance()
            if not ScopeDefinition.objects.filter():
                call_command("loaddata", "scopedefinitions")
        # we catch this error in case the database has not been migrated, b/c we can't query it until its been created
        except (OperationalError, ProgrammingError):
            pass

        # add models to be synced by profile
        add_syncable_models()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号