Python django.apps.apps 模块,app_configs() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用django.apps.apps.app_configs()

项目:django-zerodowntime    作者:rentlytics    | 项目源码 | 文件源码
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)
项目:djangoql    作者:ivelum    | 项目源码 | 文件源码
def all_models(self):
        models = []
        for app_label in apps.app_configs:
            models.extend(apps.get_app_config(app_label).get_models())
        return models
项目:gitmate-2    作者:GitMateIO    | 项目源码 | 文件源码
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)