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


Python AppConfig.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from django.apps import AppConfig [as 别名]
# 或者: from django.apps.AppConfig import __init__ [as 别名]
def __init__(self, app_label, name, fields, options=None, bases=None, managers=None):
        self.app_label = app_label
        self.name = force_text(name)
        self.fields = fields
        self.options = options or {}
        self.bases = bases or (models.Model, )
        self.managers = managers or []
        # Sanity-check that fields is NOT a dict. It must be ordered.
        if isinstance(self.fields, dict):
            raise ValueError("ModelState.fields cannot be a dict - it must be a list of 2-tuples.")
        # Sanity-check that fields are NOT already bound to a model.
        for name, field in fields:
            if hasattr(field, 'model'):
                raise ValueError(
                    'ModelState.fields cannot be bound to a model - "%s" is.' % name
                ) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:18,代码来源:state.py

示例2: __init__

# 需要导入模块: from django.apps import AppConfig [as 别名]
# 或者: from django.apps.AppConfig import __init__ [as 别名]
def __init__(self, real_apps, models, ignore_swappable=False):
        # Any apps in self.real_apps should have all their models included
        # in the render. We don't use the original model instances as there
        # are some variables that refer to the Apps object.
        # FKs/M2Ms from real apps are also not included as they just
        # mess things up with partial states (due to lack of dependencies)
        self.real_models = []
        for app_label in real_apps:
            app = global_apps.get_app_config(app_label)
            for model in app.get_models():
                self.real_models.append(ModelState.from_model(model, exclude_rels=True))
        # Populate the app registry with a stub for each application.
        app_labels = {model_state.app_label for model_state in models.values()}
        app_configs = [AppConfigStub(label) for label in sorted(real_apps + list(app_labels))]
        super(StateApps, self).__init__(app_configs)

        self.render_multiple(list(models.values()) + self.real_models)

        # There shouldn't be any operations pending at this point.
        pending_models = set(self._pending_operations)
        if ignore_swappable:
            pending_models -= {make_model_tuple(settings.AUTH_USER_MODEL)}
        if pending_models:
            raise ValueError(self._pending_models_error(pending_models)) 
开发者ID:drexly,项目名称:openhgsenti,代码行数:26,代码来源:state.py

示例3: __init__

# 需要导入模块: from django.apps import AppConfig [as 别名]
# 或者: from django.apps.AppConfig import __init__ [as 别名]
def __init__(self, models=None, real_apps=None):
        self.models = models or {}
        # Apps to include from main registry, usually unmigrated ones
        self.real_apps = real_apps or []
        self.is_delayed = False 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:7,代码来源:state.py


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