diff options
author | Alexander Sulfrian <alexander.sulfrian@fu-berlin.de> | 2018-03-21 17:32:25 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander.sulfrian@fu-berlin.de> | 2018-03-21 18:11:44 +0100 |
commit | e586c4236efbb6b639895839f123cb847d69180b (patch) | |
tree | 3cee5a9aad25d7d5986e504e015502a95813e7f7 /src/lib/Bcfg2/DBSettings.py | |
parent | 1d63db72646ab317552061bab0d56393f5f54ab4 (diff) | |
download | bcfg2-e586c4236efbb6b639895839f123cb847d69180b.tar.gz bcfg2-e586c4236efbb6b639895839f123cb847d69180b.tar.bz2 bcfg2-e586c4236efbb6b639895839f123cb847d69180b.zip |
Reporting: Fix template settings for django 1.10
Django 1.8 deprecated the multiple TEMPLATE_* settings and introduced a
single TEMPLATES config option. Django 1.10 stopped creating a
backwards-compatible TEMPLATES based on the TEMPLATE_* settings.
(See: https://docs.djangoproject.com/en/1.10/ref/templates/upgrading/#the-templates-settings)
Diffstat (limited to 'src/lib/Bcfg2/DBSettings.py')
-rw-r--r-- | src/lib/Bcfg2/DBSettings.py | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/lib/Bcfg2/DBSettings.py b/src/lib/Bcfg2/DBSettings.py index ddcf66b44..5d99d4ee2 100644 --- a/src/lib/Bcfg2/DBSettings.py +++ b/src/lib/Bcfg2/DBSettings.py @@ -56,15 +56,6 @@ settings = dict( AUTHENTICATION_BACKENDS=('django.contrib.auth.backends.ModelBackend'), LOGIN_URL='/login', SESSION_EXPIRE_AT_BROWSER_CLOSE=True, - TEMPLATE_DIRS=( - '/usr/share/python-support/python-django/django/contrib/admin/' - 'templates/'), - TEMPLATE_CONTEXT_PROCESSORS=( - 'django.contrib.auth.context_processors.auth', - 'django.core.context_processors.debug', - 'django.core.context_processors.i18n', - 'django.core.context_processors.media', - 'django.core.context_processors.request'), DATABASE_ROUTERS=['Bcfg2.DBSettings.PerApplicationRouter'], TEST_RUNNER='django.test.simple.DjangoTestSuiteRunner', CACHES={ @@ -88,6 +79,35 @@ elif HAS_SOUTH: 'Reporting': 'Bcfg2.Reporting.south_migrations', 'Server': 'Bcfg2.Server.south_migrations', } +if HAS_DJANGO and django.VERSION[0] == 1 and django.VERSION[1] >= 8: + settings['TEMPLATES'] = [{ + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + '/usr/share/python-support/python-django/' + + 'django/contrib/admin/templates/' + ], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.contrib.auth.context_processors.auth', + 'django.template.context_processors.debug', + 'django.template.context_processors.i18n', + 'django.template.context_processors.media', + 'django.template.context_processors.request', + ], + }, + }] +else: + settings['TEMPLATE_DIRS'] = ('/usr/share/python-support/python-django/' + + 'django/contrib/admin/templates/') + settings['TEMPLATE_CONTEXT_PROCESSORS'] = ( + 'django.contrib.auth.context_processors.auth', + 'django.core.context_processors.debug', + 'django.core.context_processors.i18n', + 'django.core.context_processors.media', + 'django.core.context_processors.request', + ) + if 'BCFG2_LEGACY_MODELS' in os.environ: settings['INSTALLED_APPS'] += ('Bcfg2.Server.Reports.reports',) |