當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。