From 7549c5ce46467cf86f2225e6076e614a21c103ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 5 Jan 2018 00:06:24 +0100 Subject: [PATCH] Django2 settings --- Ernestophone/settings/common.py | 26 ++++++++++++++++++++------ Ernestophone/settings/local.py | 7 ++++--- Ernestophone/urls.py | 7 +++++++ 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Ernestophone/settings/common.py b/Ernestophone/settings/common.py index 4c2539d..90350b4 100644 --- a/Ernestophone/settings/common.py +++ b/Ernestophone/settings/common.py @@ -48,12 +48,12 @@ INSTALLED_APPS = [ 'pads', ] -MIDDLEWARE_CLASSES = [ +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] @@ -72,16 +72,15 @@ TEMPLATES = [{ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', - 'django.template.context_processors.i18n', - 'django.template.context_processors.media', - 'django.template.context_processors.static', ], } }] +WSGI_APPLICATION = "Ernestophone.wsgi.application" + DATABASES = { "default": { - "ENGINE": "django.db.backends.postgresql_psycopg2", + "ENGINE": "django.db.backends.postgresql", "NAME": DBNAME, "USER": DBUSER, "PASSWORD": DBPASSWD, @@ -89,6 +88,21 @@ DATABASES = { } } +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + # I18n LANGUAGE_CODE = 'fr-fr' diff --git a/Ernestophone/settings/local.py b/Ernestophone/settings/local.py index 08c7016..ff331d4 100644 --- a/Ernestophone/settings/local.py +++ b/Ernestophone/settings/local.py @@ -2,7 +2,7 @@ import os from .common import * # noqa -from .common import BASE_DIR, INSTALLED_APPS, MIDDLEWARE_CLASSES +from .common import BASE_DIR, INSTALLED_APPS, MIDDLEWARE EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" @@ -10,13 +10,14 @@ EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" DEBUG = True INSTALLED_APPS += ["debug_toolbar"] -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = ( ["debug_toolbar.middleware.DebugToolbarMiddleware"] - + MIDDLEWARE_CLASSES + + MIDDLEWARE ) STATIC_URL = "/static/" MEDIA_URL = "/media/" +MEDIA_ROOT = "media" DATABASES = { "default": { diff --git a/Ernestophone/urls.py b/Ernestophone/urls.py index a4c3413..f6fb3c5 100644 --- a/Ernestophone/urls.py +++ b/Ernestophone/urls.py @@ -30,4 +30,11 @@ urlpatterns = [ path("divers/", gestion_views.divers), ] +if "debug_toolbar" in settings.INSTALLED_APPS: + import debug_toolbar + from django.conf.urls import include, url + urlpatterns = [ + url(r"^__debug__/", include(debug_toolbar.urls)), + ] + urlpatterns + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)