python类app_configs()的实例源码

test_migration_utils.py 文件源码 项目:django-zerodowntime 作者: rentlytics 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def reinitialize_django_apps(self):
        apps.app_configs = OrderedDict()
        # set ready to false so that populate will work
        apps.ready = False
        # re-initialize them all; is there a way to add just one without reloading them all?
        apps.populate(settings.INSTALLED_APPS)
test_schema.py 文件源码 项目:djangoql 作者: ivelum 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def all_models(self):
        models = []
        for app_label in apps.app_configs:
            models.extend(apps.get_app_config(app_label).get_models())
        return models
test_base.py 文件源码 项目:gitmate-2 作者: GitMateIO 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def reinit_plugin(name, upmate: bool=False):  # pragma: no cover
    """
    Reinitialize gitmate with plugin and upmate, if specified.
    """
    app_name = 'gitmate_' + name
    app_config_name = 'plugins.{}.apps.{}Config'.format(
        app_name, snake_case_to_camel_case(app_name))

    if app_config_name in settings.INSTALLED_APPS:
        return

    settings.GITMATE_PLUGINS += [name]
    settings.INSTALLED_APPS += [app_config_name]
    # To load the new app let's reset app_configs, the dictionary
    # with the configuration of loaded apps
    apps.app_configs = OrderedDict()
    # set ready to false so that populate will work
    apps.ready = False
    # re-initialize them all
    apps.populate(settings.INSTALLED_APPS)

    # migrate the models
    management.call_command('migrate', app_name, interactive=False)

    # upmate the plugins, if specified
    if upmate is True:
        management.call_command('upmate', interactive=False)


问题


面经


文章

微信
公众号

扫码关注公众号