]> git.parisson.com Git - telemeta.git/commitdiff
Upgrading templates to Django 1.8 - TEMPLATES settings
authorThomas Fillon <thomas@parisson.com>
Wed, 25 Jan 2017 17:26:19 +0000 (18:26 +0100)
committerThomas Fillon <thomas@parisson.com>
Wed, 25 Jan 2017 17:26:19 +0000 (18:26 +0100)
app/settings.py

index 051e540eb6959de90574047e927964cc8ab167dc..d23ee2c8a13b37df2cf68192dd70e1b9e90023b4 100644 (file)
@@ -1,7 +1,8 @@
 # -*- coding: utf-8 -*-
 # Django settings for sandbox project.
 
-import os, sys
+import os
+import sys
 from django.core.urlresolvers import reverse_lazy, reverse
 
 import environ
@@ -11,8 +12,8 @@ env = environ.Env(DEBUG=(bool, False),
                   )
 
 # Django settings for server project.
-DEBUG = env('DEBUG') # False if not in os.environ
-TEMPLATE_DEBUG = DEBUG
+DEBUG = env('DEBUG')  # False if not in os.environ
+
 
 sys.dont_write_bytecode = True
 
@@ -52,14 +53,14 @@ TIME_ZONE = 'Europe/Paris'
 # http://www.i18nguy.com/unicode/language-identifiers.html
 #LANGUAGE_CODE = 'fr_FR'
 
-LANGUAGES = [ ('fr', 'French'),
-              ('en', 'English'),
-              ('de', 'German'),
-              ('zh_CN', 'Simplified Chinese'),
-              ('ar_TN', 'Arabic'),
-              ('pt_BR', 'Portuguese'),
-              ('es', 'Spanish'),
-]
+LANGUAGES = [('fr', 'French'),
+             ('en', 'English'),
+             ('de', 'German'),
+             ('zh_CN', 'Simplified Chinese'),
+             ('ar_TN', 'Arabic'),
+             ('pt_BR', 'Portuguese'),
+             ('es', 'Spanish'),
+             ]
 
 SITE_ID = 1
 
@@ -97,29 +98,46 @@ STATIC_URL = '/static/'
 
 # Additional locations of static files
 STATICFILES_DIRS = (
-# Put strings here, like "/home/html/static" or "C:/www/django/static".
-# Always use forward slashes, even on Windows.
-# Don't forget to use absolute paths, not relative paths.
+    # Put strings here, like "/home/html/static" or "C:/www/django/static".
+    # Always use forward slashes, even on Windows.
+    # Don't forget to use absolute paths, not relative paths.
 )
 
 # List of finder classes that know how to find static files in
 # various locations.
 STATICFILES_FINDERS = (
-'django.contrib.staticfiles.finders.FileSystemFinder',
-'django.contrib.staticfiles.finders.AppDirectoriesFinder',
-'djangobower.finders.BowerFinder',
-#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
+    'django.contrib.staticfiles.finders.FileSystemFinder',
+    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
+    'djangobower.finders.BowerFinder',
+    #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
 )
 # Make this unique, and don't share it with anybody.
 SECRET_KEY = 'a8l7%06wr2k+3=%#*#@#rvop2mmzko)44%7k(zx%lls^ihm9^5'
 
-# List of callables that know how to import templates from various sources.
-TEMPLATE_LOADERS = (
-    'django.template.loaders.filesystem.Loader',
-    'django.template.loaders.app_directories.Loader',
-#     'django.template.loaders.eggs.Loader',
-)
-
+TEMPLATES = [
+    {
+        'BACKEND': 'django.template.backends.django.DjangoTemplates',
+        'DEBUG': DEBUG,
+        'DIRS': [
+            # insert your TEMPLATE_DIRS here
+        ],
+        'APP_DIRS': True,
+        'OPTIONS': {
+            'context_processors': [
+                # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
+                # list if you haven't customized them:
+                'django.core.context_processors.request',
+                '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.static',
+                'django.template.context_processors.tz',
+                'django.contrib.messages.context_processors.messages',
+            ],
+        },
+    },
+]
 
 MIDDLEWARE_CLASSES = (
     # Manage Django URLs for AngularJS with django-angular
@@ -135,12 +153,6 @@ MIDDLEWARE_CLASSES = (
 
 ROOT_URLCONF = 'urls'
 
-TEMPLATE_DIRS = (
-    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
-    # Always use forward slashes, even on Windows.
-    # Don't forget to use absolute paths, not relative paths.
-)
-
 INSTALLED_APPS = (
     'django.contrib.auth',
     'django.contrib.contenttypes',
@@ -172,14 +184,6 @@ INSTALLED_APPS = (
     'saved_searches',
 )
 
-TEMPLATE_CONTEXT_PROCESSORS = (
-    'django.core.context_processors.request',
-    'django.contrib.auth.context_processors.auth',
-    "django.core.context_processors.i18n",
-    "django.core.context_processors.media",
-    'django.core.context_processors.static',
-    'django.contrib.messages.context_processors.messages',
-)
 
 AUTHENTICATION_BACKENDS = (
     'django.contrib.auth.backends.ModelBackend',
@@ -240,7 +244,7 @@ PAGINATION_SETTINGS = {
 }
 if DEBUG:
     DEBUG_TOOLBAR_CONFIG = {
-        'SHOW_TOOLBAR_CALLBACK': lambda x : True
+        'SHOW_TOOLBAR_CALLBACK': lambda x: True
     }
 DEBUG_TOOLBAR_PATCH_SETTINGS = False
 DEBUG_TOOLBAR_PANELS = [