From fee846019b501c175aa883bb8babfa0d438d2be8 Mon Sep 17 00:00:00 2001 From: Takuya Noguchi Date: Wed, 25 Oct 2017 00:38:42 +0900 Subject: [PATCH 1/3] Update django-debug-toolbar to 1.8 --- project/settings.py | 2 ++ project/urls.py | 7 +++++++ requirements.txt | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/project/settings.py b/project/settings.py index 99c6b624..191814f9 100644 --- a/project/settings.py +++ b/project/settings.py @@ -110,3 +110,5 @@ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' + +INTERNAL_IPS = ['127.0.0.1'] diff --git a/project/urls.py b/project/urls.py index 7165878d..5c6a8e36 100644 --- a/project/urls.py +++ b/project/urls.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.conf.urls import include, url from django.contrib import admin @@ -12,3 +13,9 @@ urlpatterns = [ url(r'^health$', health), url(r'^admin/', include(admin.site.urls)), ] + +if settings.DEBUG: + import debug_toolbar + urlpatterns = [ + url(r'^__debug__/', include(debug_toolbar.urls)), + ] + urlpatterns diff --git a/requirements.txt b/requirements.txt index 08db2890..0c0e4ebe 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ django>=1.8,<1.9 -django-debug-toolbar==1.5 +django-debug-toolbar==1.8 gunicorn==19.4.5 psycopg2==2.7.3.1 whitenoise==3.0 From a6979d731a31052f4756eb21ee7ca3813291e080 Mon Sep 17 00:00:00 2001 From: Takuya Noguchi Date: Wed, 25 Oct 2017 00:39:03 +0900 Subject: [PATCH 2/3] Update whitenoise to 3.3.1 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0c0e4ebe..f5c00acc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,4 @@ django>=1.8,<1.9 django-debug-toolbar==1.8 gunicorn==19.4.5 psycopg2==2.7.3.1 -whitenoise==3.0 +whitenoise==3.3.1 From 638277ed07dccb2510b68a7394ef1233a765cf40 Mon Sep 17 00:00:00 2001 From: Takuya Noguchi Date: Wed, 25 Oct 2017 00:42:43 +0900 Subject: [PATCH 3/3] Update django to 1.11.x --- project/settings.py | 47 +++++++++++++++++++--------- requirements.txt | 2 +- welcome/templates/welcome/index.html | 4 +-- wsgi.py | 2 +- 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/project/settings.py b/project/settings.py index 191814f9..8855547e 100644 --- a/project/settings.py +++ b/project/settings.py @@ -1,23 +1,23 @@ """ Django settings for this project. -Generated by 'django-admin startproject' using Django 1.8.1. +Generated by 'django-admin startproject' using Django 1.11.6. For more information on this file, see -https://docs.djangoproject.com/en/1.8/topics/settings/ +https://docs.djangoproject.com/en/1.11/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/1.8/ref/settings/ +https://docs.djangoproject.com/en/1.11/ref/settings/ """ -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! # The SECRET_KEY is provided via an environment variable in OpenShift @@ -35,7 +35,7 @@ ALLOWED_HOSTS = ['*'] # Application definition -INSTALLED_APPS = ( +INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -44,19 +44,19 @@ INSTALLED_APPS = ( 'django.contrib.staticfiles', 'debug_toolbar', 'welcome', -) +] -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', - 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', -) + 'debug_toolbar.middleware.DebugToolbarMiddleware', +] ROOT_URLCONF = 'project.urls' @@ -80,7 +80,7 @@ WSGI_APPLICATION = 'wsgi.application' # Database -# https://docs.djangoproject.com/en/1.8/ref/settings/#databases +# https://docs.djangoproject.com/en/1.11/ref/settings/#databases from . import database @@ -89,8 +89,27 @@ DATABASES = { } +# Password validation +# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators + +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', + }, +] + + # Internationalization -# https://docs.djangoproject.com/en/1.8/topics/i18n/ +# https://docs.djangoproject.com/en/1.11/topics/i18n/ LANGUAGE_CODE = 'en-us' @@ -104,7 +123,7 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/1.8/howto/static-files/ +# https://docs.djangoproject.com/en/1.11/howto/static-files/ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') diff --git a/requirements.txt b/requirements.txt index f5c00acc..4885bf17 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -django>=1.8,<1.9 +django>=1.11,<1.12 django-debug-toolbar==1.8 gunicorn==19.4.5 psycopg2==2.7.3.1 diff --git a/welcome/templates/welcome/index.html b/welcome/templates/welcome/index.html index 5c5bafef..5357f9bd 100644 --- a/welcome/templates/welcome/index.html +++ b/welcome/templates/welcome/index.html @@ -263,14 +263,14 @@ $ git push

Now it is time to add your own code. - Follow along the Django tutorial to learn more about Django. + Follow along the Django tutorial to learn more about Django.

If you are running Django's development server in your local host, you can see more information about this request using the toolbar on the right.
Please note that by default your Django settings have DEBUG = True and that is not appropriate for production use, but very handy during development.
- Refer to the Deployment Checklist + Refer to the Deployment Checklist before taking this project into a production environment.

diff --git a/wsgi.py b/wsgi.py index 7c2f625e..2ef9a16d 100644 --- a/wsgi.py +++ b/wsgi.py @@ -4,7 +4,7 @@ WSGI config for project project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see -https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/ """ import os