当前位置: 首页>>代码示例>>Python>>正文


Python apps.app_configs方法代码示例

本文整理汇总了Python中django.apps.apps.app_configs方法的典型用法代码示例。如果您正苦于以下问题:Python apps.app_configs方法的具体用法?Python apps.app_configs怎么用?Python apps.app_configs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.apps.apps的用法示例。


在下文中一共展示了apps.app_configs方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: define_fake_model

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import app_configs [as 别名]
def define_fake_model(
    fields=None, model_base=PostgresModel, meta_options={}, **attributes
):
    """Defines a fake model (but does not create it in the database)."""

    name = str(uuid.uuid4()).replace("-", "")[:8].title()

    attributes = {
        "app_label": meta_options.get("app_label") or "tests",
        "__module__": __name__,
        "__name__": name,
        "Meta": type("Meta", (object,), meta_options),
        **attributes,
    }

    if fields:
        attributes.update(fields)

    model = type(name, (model_base,), attributes)

    apps.app_configs[attributes["app_label"]].models[name] = model
    return model 
开发者ID:SectorLabs,项目名称:django-postgres-extra,代码行数:24,代码来源:fake_model.py

示例2: define_fake_app

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import app_configs [as 别名]
def define_fake_app():
    """Creates and registers a fake Django app."""

    name = str(uuid.uuid4()).replace("-", "")[:8] + "-app"

    app_config_cls = type(
        name + "Config",
        (AppConfig,),
        {"name": name, "path": os.path.dirname(__file__)},
    )

    app_config = app_config_cls(name, "")
    app_config.apps = apps
    app_config.models = {}

    apps.app_configs[name] = app_config
    sys.modules[name] = {}

    try:
        yield app_config
    finally:
        del apps.app_configs[name]
        del sys.modules[name] 
开发者ID:SectorLabs,项目名称:django-postgres-extra,代码行数:25,代码来源:fake_model.py

示例3: simulate_checks

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import app_configs [as 别名]
def simulate_checks():
    app_configs = apps.app_configs
    errors = []
    all_checks = registry.get_checks(False)
    rest_registration_checks = [
        check for check in all_checks
        if check.__module__.startswith('rest_registration.')
    ]
    for check in rest_registration_checks:
        errors.extend(check(app_configs))
    return errors 
开发者ID:apragacz,项目名称:django-rest-registration,代码行数:13,代码来源:test_checks.py

示例4: setUp

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import app_configs [as 别名]
def setUp(self):
        # Taken from IsolatedModelsTestCase in
        # django/tests/invalid_models_tests/base.py
        from django.apps import apps

        self._old_models = apps.app_configs["tests"].models.copy() 
开发者ID:MarkusH,项目名称:django-osm-field,代码行数:8,代码来源:test_fields.py

示例5: tearDown

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import app_configs [as 别名]
def tearDown(self):
        # Taken from IsolatedModelsTestCase in
        # django/tests/invalid_models_tests/base.py
        from django.apps import apps

        apps.app_configs["tests"].models = self._old_models
        apps.all_models["tests"] = self._old_models
        apps.clear_cache() 
开发者ID:MarkusH,项目名称:django-osm-field,代码行数:10,代码来源:test_fields.py

示例6: get_context_data

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import app_configs [as 别名]
def get_context_data(self, **kwargs):
        context = super(IndexView, self).get_context_data(**kwargs)
        app_list = []
        for app_name, app_config in apps.app_configs.items():
            if getattr(app_config, "events_module", None) is not None:
                app_list.append(app_name)
        app_list.sort()
        context["apps"] = app_list
        return context 
开发者ID:zentralopensource,项目名称:zentral,代码行数:11,代码来源:views.py

示例7: get

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import app_configs [as 别名]
def get(self, request, *args, **kwargs):
        app = kwargs['app']
        try:
            zentral_app = apps.app_configs[app]
            search_dict = getattr(zentral_app.events_module, "ALL_EVENTS_SEARCH_DICT")
        except (KeyError, AttributeError):
            raise Http404
        interval = kwargs["interval"]
        try:
            date_format = self.INTERVAL_DATE_FORMAT[interval]
        except KeyError:
            raise Http404
        labels = []
        event_count_data = []
        unique_msn_data = []
        for dt, event_count, unique_msn in frontend_store.get_app_hist_data(interval, int(kwargs["bucket_number"]),
                                                                            **search_dict):
            labels.append(dt.strftime(date_format))
            event_count_data.append(event_count)
            unique_msn_data.append(unique_msn)
        datasets = {"event_count": {
                        "label": "{} events".format(app),
                        "backgroundColor": "rgba(120, 198, 188, 0.7)",
                        "data": event_count_data
                    },
                    "unique_msn": {
                        "label": "{} machines".format(app),
                        "backgroundColor": "rgba(234, 81, 100, 0.7)",
                        "data": unique_msn_data
                    }}
        return JsonResponse({"app": app,
                             "labels": labels,
                             "datasets": datasets}) 
开发者ID:zentralopensource,项目名称:zentral,代码行数:35,代码来源:views.py

示例8: all_models

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import app_configs [as 别名]
def all_models(self):
        models = []
        for app_label in apps.app_configs:
            models.extend(apps.get_app_config(app_label).get_models())
        return models 
开发者ID:ivelum,项目名称:djangoql,代码行数:7,代码来源:test_schema.py

示例9: setUp

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import app_configs [as 别名]
def setUp(self):
        super(MakeMigrationsTests, self).setUp()
        self._old_models = apps.app_configs['migrations'].models.copy() 
开发者ID:denisenkom,项目名称:django-sqlserver,代码行数:5,代码来源:test_commands.py

示例10: tearDown

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import app_configs [as 别名]
def tearDown(self):
        apps.app_configs['migrations'].models = self._old_models
        apps.all_models['migrations'] = self._old_models
        apps.clear_cache()
        super(MakeMigrationsTests, self).tearDown() 
开发者ID:denisenkom,项目名称:django-sqlserver,代码行数:7,代码来源:test_commands.py

示例11: setUp

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import app_configs [as 别名]
def setUp(self):
        super().setUp()
        self._old_models = apps.app_configs['migrations'].models.copy() 
开发者ID:nesdis,项目名称:djongo,代码行数:5,代码来源:test_commands.py

示例12: tearDown

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import app_configs [as 别名]
def tearDown(self):
        apps.app_configs['migrations'].models = self._old_models
        apps.all_models['migrations'] = self._old_models
        apps.clear_cache()
        super().tearDown() 
开发者ID:nesdis,项目名称:djongo,代码行数:7,代码来源:test_commands.py

示例13: setUp

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import app_configs [as 别名]
def setUp(self):
        # The unmanaged models need to be removed after the test in order to
        # prevent bad interactions with the flush operation in other tests.
        self._old_models = apps.app_configs['model_options'].models.copy()

        for model in Article, Authors, Reviewers, Scientist:
            model._meta.managed = True 
开发者ID:nesdis,项目名称:djongo,代码行数:9,代码来源:test_tablespaces.py

示例14: tearDown

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import app_configs [as 别名]
def tearDown(self):
        for model in Article, Authors, Reviewers, Scientist:
            model._meta.managed = False

        apps.app_configs['model_options'].models = self._old_models
        apps.all_models['model_options'] = self._old_models
        apps.clear_cache() 
开发者ID:nesdis,项目名称:djongo,代码行数:9,代码来源:test_tablespaces.py


注:本文中的django.apps.apps.app_configs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。