Python django.conf.settings.DATABASE_ROUTERS Examples
The following are 14
code examples of django.conf.settings.DATABASE_ROUTERS().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.conf.settings
, or try the search function
.
Example #1
Source File: utils.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def __init__(self, routers=None): """ If routers is not specified, will default to settings.DATABASE_ROUTERS. """ self._routers = routers
Example #2
Source File: utils.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
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
Example #3
Source File: utils.py From bioforum with MIT License | 5 votes |
def __init__(self, routers=None): """ If routers is not specified, default to settings.DATABASE_ROUTERS. """ self._routers = routers
Example #4
Source File: utils.py From bioforum with MIT License | 5 votes |
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
Example #5
Source File: apps.py From django-tenants with MIT License | 5 votes |
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))
Example #6
Source File: utils.py From Hands-On-Application-Development-with-PyCharm with MIT License | 5 votes |
def __init__(self, routers=None): """ If routers is not specified, default to settings.DATABASE_ROUTERS. """ self._routers = routers
Example #7
Source File: utils.py From Hands-On-Application-Development-with-PyCharm with MIT License | 5 votes |
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
Example #8
Source File: utils.py From python with Apache License 2.0 | 5 votes |
def __init__(self, routers=None): """ If routers is not specified, will default to settings.DATABASE_ROUTERS. """ self._routers = routers
Example #9
Source File: utils.py From python with Apache License 2.0 | 5 votes |
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
Example #10
Source File: utils.py From openhgsenti with Apache License 2.0 | 5 votes |
def __init__(self, routers=None): """ If routers is not specified, will default to settings.DATABASE_ROUTERS. """ self._routers = routers
Example #11
Source File: utils.py From openhgsenti with Apache License 2.0 | 5 votes |
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
Example #12
Source File: utils.py From python2017 with MIT License | 5 votes |
def __init__(self, routers=None): """ If routers is not specified, will default to settings.DATABASE_ROUTERS. """ self._routers = routers
Example #13
Source File: utils.py From python2017 with MIT License | 5 votes |
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
Example #14
Source File: apps.py From django-pgschemas with MIT License | 5 votes |
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'.")