summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/DBSettings.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Bcfg2/DBSettings.py')
-rw-r--r--src/lib/Bcfg2/DBSettings.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/lib/Bcfg2/DBSettings.py b/src/lib/Bcfg2/DBSettings.py
index 3b5cbbbd8..254dfa4b8 100644
--- a/src/lib/Bcfg2/DBSettings.py
+++ b/src/lib/Bcfg2/DBSettings.py
@@ -65,7 +65,12 @@ settings = dict( # pylint: disable=C0103
'django.core.context_processors.media',
'django.core.context_processors.request'),
DATABASE_ROUTERS=['Bcfg2.DBSettings.PerApplicationRouter'],
- TEST_RUNNER='django.test.simple.DjangoTestSuiteRunner')
+ TEST_RUNNER='django.test.simple.DjangoTestSuiteRunner',
+ CACHES={
+ 'default': {
+ 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
+ }
+ })
if HAS_DJANGO and django.VERSION[0] == 1 and django.VERSION[1] >= 6:
settings['MIDDLEWARE_CLASSES'] += \
@@ -85,15 +90,6 @@ elif HAS_SOUTH:
if 'BCFG2_LEGACY_MODELS' in os.environ:
settings['INSTALLED_APPS'] += ('Bcfg2.Server.Reports.reports',)
-if HAS_DJANGO and django.VERSION[0] == 1 and django.VERSION[1] < 3:
- settings['CACHE_BACKEND'] = 'locmem:///'
-else:
- settings['CACHES'] = {
- 'default': {
- 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
- }
- }
-
def finalize_django_config(opts=None, silent=False):
""" Perform final Django configuration """
@@ -147,6 +143,8 @@ def finalize_django_config(opts=None, silent=False):
setattr(module, name, value)
try:
django.conf.settings.configure(**settings)
+ if django.VERSION[0] == 1 and django.VERSION[1] >= 7:
+ django.setup() # pylint: disable=E1101
except RuntimeError:
if not silent:
logger.warning("Failed to finalize Django settings: %s" %
@@ -208,7 +206,6 @@ def migrate_databases(**kwargs):
for database in settings['DATABASES']:
logger.debug("Migrating database %s" % (database))
if django.VERSION[0] == 1 and django.VERSION[1] >= 7:
- django.setup() # pylint: disable=E1101
if initial_django_migration(database):
logger.warning(
"No applied django migrations found for database %s. "