當前位置: 首頁>>代碼示例>>Python>>正文


Python apps.populate方法代碼示例

本文整理匯總了Python中django.apps.apps.populate方法的典型用法代碼示例。如果您正苦於以下問題:Python apps.populate方法的具體用法?Python apps.populate怎麽用?Python apps.populate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.apps.apps的用法示例。


在下文中一共展示了apps.populate方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setup

# 需要導入模塊: from django.apps import apps [as 別名]
# 或者: from django.apps.apps import populate [as 別名]
def setup(set_prefix=True):
    """
    Configure the settings (this happens as a side effect of accessing the
    first setting), configure logging and populate the app registry.
    Set the thread-local urlresolvers script prefix if `set_prefix` is True.
    """
    from django.apps import apps
    from django.conf import settings
    from django.urls import set_script_prefix
    from django.utils.log import configure_logging

    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
    if set_prefix:
        set_script_prefix(
            '/' if settings.FORCE_SCRIPT_NAME is None else settings.FORCE_SCRIPT_NAME
        )
    apps.populate(settings.INSTALLED_APPS) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:19,代碼來源:__init__.py

示例2: setup_django

# 需要導入模塊: from django.apps import apps [as 別名]
# 或者: from django.apps.apps import populate [as 別名]
def setup_django():
    import django
    from django.conf import settings
    if not settings.configured:
        settings.configure(
            DEBUG=True,
            DATABASES={
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    'NAME': ':memory:',
                }
            },
            INSTALLED_APPS=(
                'django.contrib.admin',
                'django.contrib.auth',
                'django.contrib.contenttypes',
                'django.contrib.sessions',
                'django.contrib.messages',
                'django_ftpserver',
            )
        )
    django.setup()
    from django.apps import apps
    if not apps.ready:
        apps.populate() 
開發者ID:tokibito,項目名稱:django-ftpserver,代碼行數:27,代碼來源:conf.py

示例3: setup

# 需要導入模塊: from django.apps import apps [as 別名]
# 或者: from django.apps.apps import populate [as 別名]
def setup(set_prefix=True):
    """
    Configure the settings (this happens as a side effect of accessing the
    first setting), configure logging and populate the app registry.
    Set the thread-local urlresolvers script prefix if `set_prefix` is True.
    """
    from django.apps import apps
    from django.conf import settings
    from django.urls import set_script_prefix
    from django.utils.encoding import force_text
    from django.utils.log import configure_logging

    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
    if set_prefix:
        set_script_prefix(
            '/' if settings.FORCE_SCRIPT_NAME is None else force_text(settings.FORCE_SCRIPT_NAME)
        )
    apps.populate(settings.INSTALLED_APPS) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:20,代碼來源:__init__.py

示例4: setup

# 需要導入模塊: from django.apps import apps [as 別名]
# 或者: from django.apps.apps import populate [as 別名]
def setup():
    """
    Configure the settings (this happens as a side effect of accessing the
    first setting), configure logging and populate the app registry.
    """
    from django.apps import apps
    from django.conf import settings
    from django.utils.log import configure_logging

    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
    apps.populate(settings.INSTALLED_APPS) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:13,代碼來源:__init__.py

示例5: model_unpickle

# 需要導入模塊: from django.apps import apps [as 別名]
# 或者: from django.apps.apps import populate [as 別名]
def model_unpickle(model_id, attrs, factory):
    """
    Used to unpickle Model subclasses with deferred fields.
    """
    if isinstance(model_id, tuple):
        if not apps.ready:
            apps.populate(settings.INSTALLED_APPS)
        model = apps.get_model(*model_id)
    else:
        # Backwards compat - the model was cached directly in earlier versions.
        model = model_id
    cls = factory(model, attrs)
    return cls.__new__(cls) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:15,代碼來源:base.py

示例6: populate_apps

# 需要導入模塊: from django.apps import apps [as 別名]
# 或者: from django.apps.apps import populate [as 別名]
def populate_apps():
    from django.apps import apps
    from django.conf import settings
    apps.populate(settings.INSTALLED_APPS) 
開發者ID:cartologic,項目名稱:cartoview,代碼行數:6,代碼來源:utils.py

示例7: initialize_django

# 需要導入模塊: from django.apps import apps [as 別名]
# 或者: from django.apps.apps import populate [as 別名]
def initialize_django(settings_module: str) -> Tuple['Apps', 'LazySettings']:
    with temp_environ():
        os.environ['DJANGO_SETTINGS_MODULE'] = settings_module

        # add current directory to sys.path
        sys.path.append(os.getcwd())

        def noop_class_getitem(cls, key):
            return cls

        from django.db import models

        models.QuerySet.__class_getitem__ = classmethod(noop_class_getitem)  # type: ignore
        models.Manager.__class_getitem__ = classmethod(noop_class_getitem)  # type: ignore

        from django.conf import settings
        from django.apps import apps

        apps.get_models.cache_clear()  # type: ignore
        apps.get_swappable_settings_name.cache_clear()  # type: ignore

        if not settings.configured:
            settings._setup()

        apps.populate(settings.INSTALLED_APPS)

    assert apps.apps_ready
    assert settings.configured

    return apps, settings 
開發者ID:typeddjango,項目名稱:django-stubs,代碼行數:32,代碼來源:context.py


注:本文中的django.apps.apps.populate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。