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


Python settings.DATABASE_ROUTERS属性代码示例

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


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

示例1: __init__

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import DATABASE_ROUTERS [as 别名]
def __init__(self, routers=None):
        """
        If routers is not specified, will default to settings.DATABASE_ROUTERS.
        """
        self._routers = routers 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:7,代码来源:utils.py

示例2: routers

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import DATABASE_ROUTERS [as 别名]
def routers(self):
        if self._routers is None:
            self._routers = settings.DATABASE_ROUTERS
        routers = []
        for r in self._routers:
            if isinstance(r, six.string_types):
                router = import_string(r)()
            else:
                router = r
            routers.append(router)
        return routers 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:13,代码来源:utils.py

示例3: __init__

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import DATABASE_ROUTERS [as 别名]
def __init__(self, routers=None):
        """
        If routers is not specified, default to settings.DATABASE_ROUTERS.
        """
        self._routers = routers 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:7,代码来源:utils.py

示例4: routers

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import DATABASE_ROUTERS [as 别名]
def routers(self):
        if self._routers is None:
            self._routers = settings.DATABASE_ROUTERS
        routers = []
        for r in self._routers:
            if isinstance(r, str):
                router = import_string(r)()
            else:
                router = r
            routers.append(router)
        return routers 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:13,代码来源:utils.py

示例5: ready

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import DATABASE_ROUTERS [as 别名]
def ready(self):
        from django.db import connection

        # Test for configuration recommendations. These are best practices,
        # they avoid hard to find bugs and unexpected behaviour.
        if not hasattr(settings, 'TENANT_APPS'):
            raise ImproperlyConfigured('TENANT_APPS setting not set')

        if not settings.TENANT_APPS:
            raise ImproperlyConfigured("TENANT_APPS is empty. "
                                       "Maybe you don't need this app?")

        if not hasattr(settings, 'TENANT_MODEL'):
            raise ImproperlyConfigured('TENANT_MODEL setting not set')

        if 'django_tenants.routers.TenantSyncRouter' not in settings.DATABASE_ROUTERS:
            raise ImproperlyConfigured("DATABASE_ROUTERS setting must contain "
                                       "'django_tenants.routers.TenantSyncRouter'.")

        if hasattr(settings, 'PG_EXTRA_SEARCH_PATHS'):
            if get_public_schema_name() in settings.PG_EXTRA_SEARCH_PATHS:
                raise ImproperlyConfigured(
                    "%s can not be included on PG_EXTRA_SEARCH_PATHS."
                    % get_public_schema_name())

            # make sure no tenant schema is in settings.PG_EXTRA_SEARCH_PATHS

            # first check that the model table is created
            model = get_tenant_model()
            c = connection.cursor()
            c.execute(
                'SELECT 1 FROM information_schema.tables WHERE table_name = %s;',
                [model._meta.db_table]
            )
            if c.fetchone():
                invalid_schemas = set(settings.PG_EXTRA_SEARCH_PATHS).intersection(
                    model.objects.all().values_list('schema_name', flat=True))
                if invalid_schemas:
                    raise ImproperlyConfigured(
                        "Do not include tenant schemas (%s) on PG_EXTRA_SEARCH_PATHS."
                        % list(invalid_schemas)) 
开发者ID:django-tenants,项目名称:django-tenants,代码行数:43,代码来源:apps.py

示例6: _check_complementary_settings

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import DATABASE_ROUTERS [as 别名]
def _check_complementary_settings(self):
        if "django_pgschemas.routers.SyncRouter" not in settings.DATABASE_ROUTERS:
            raise ImproperlyConfigured("DATABASE_ROUTERS setting must contain 'django_pgschemas.routers.SyncRouter'.") 
开发者ID:lorinkoz,项目名称:django-pgschemas,代码行数:5,代码来源:apps.py


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