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


Python apps.ready方法代码示例

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


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

示例1: setup_django

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import ready [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

示例2: mock_django_setup

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import ready [as 别名]
def mock_django_setup(settings_module, disabled_features=None):
    """ Must be called *AT IMPORT TIME* to pretend that Django is set up.

    This is useful for running tests without using the Django test runner.
    This must be called before any Django models are imported, or they will
    complain. Call this from a module in the calling project at import time,
    then be sure to import that module at the start of all mock test modules.
    Another option is to call it from the test package's init file, so it runs
    before all the test modules are imported.
    :param settings_module: the module name of the Django settings file,
        like 'myapp.settings'
    :param disabled_features: a list of strings that should be marked as
        *False* on the connection features list. All others will default
        to True.
    """
    if apps.ready:
        # We're running in a real Django unit test, don't do anything.
        return

    if 'DJANGO_SETTINGS_MODULE' not in os.environ:
        os.environ['DJANGO_SETTINGS_MODULE'] = settings_module
    django.setup()
    mock_django_connection(disabled_features) 
开发者ID:stphivos,项目名称:django-mock-queries,代码行数:25,代码来源:mocks.py

示例3: model_unpickle

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import ready [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

示例4: _django_setup

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import ready [as 别名]
def _django_setup():
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rssant.settings')
    if not apps.ready and not settings.configured:
        django.setup() 
开发者ID:anyant,项目名称:rssant,代码行数:6,代码来源:django_setup.py

示例5: check_debug

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import ready [as 别名]
def check_debug():
    """Check that Django's template debugging is enabled.

    Django's built-in "template debugging" records information the plugin needs
    to do its work.  Check that the setting is correct, and raise an exception
    if it is not.

    Returns True if the debug check was performed, False otherwise
    """
    from django.conf import settings

    if not settings.configured:
        return False

    # I _think_ this check is all that's needed and the 3 "hasattr" checks
    # below can be removed, but it's not clear how to verify that
    from django.apps import apps
    if not apps.ready:
        return False

    # django.template.backends.django gets loaded lazily, so return false
    # until they've been loaded
    if not hasattr(django.template, "backends"):
        return False
    if not hasattr(django.template.backends, "django"):
        return False
    if not hasattr(django.template.backends.django, "DjangoTemplates"):
        raise DjangoTemplatePluginException("Can't use non-Django templates.")

    for engine in django.template.engines.all():
        if not isinstance(engine, django.template.backends.django.DjangoTemplates):
            raise DjangoTemplatePluginException(
                "Can't use non-Django templates."
            )
        if not engine.engine.debug:
            raise DjangoTemplatePluginException(
                "Template debugging must be enabled in settings."
            )

    return True 
开发者ID:nedbat,项目名称:django_coverage_plugin,代码行数:42,代码来源:plugin.py

示例6: test_ready

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import ready [as 别名]
def test_ready(self):
        """
        Tests the ready property of the master registry.
        """
        # The master app registry is always ready when the tests run.
        self.assertIs(apps.ready, True)
        # Non-master app registries are populated in __init__.
        self.assertIs(Apps().ready, True) 
开发者ID:nesdis,项目名称:djongo,代码行数:10,代码来源:tests.py


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