Commit e332ad5a by Kenneth Reitz

Merge pull request #37 from edmorley/update-whitenoise

Update to WhiteNoise 3.2
parents 77f8aac6 289a6d5f
...@@ -28,16 +28,22 @@ DEBUG = True ...@@ -28,16 +28,22 @@ DEBUG = True
# Application definition # Application definition
INSTALLED_APPS = ( INSTALLED_APPS = [
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
# Disable Django's own staticfiles handling in favour of WhiteNoise, for
# greater consistency between gunicorn and `./manage.py runserver`. See:
# http://whitenoise.evans.io/en/stable/django.html#using-whitenoise-in-development
'whitenoise.runserver_nostatic',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
) ]
MIDDLEWARE_CLASSES = ( MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
...@@ -45,12 +51,11 @@ MIDDLEWARE_CLASSES = ( ...@@ -45,12 +51,11 @@ MIDDLEWARE_CLASSES = (
'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware', ]
)
ROOT_URLCONF = '{{ project_name }}.urls' ROOT_URLCONF = '{{ project_name }}.urls'
TEMPLATES = ( TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [], 'DIRS': [],
...@@ -65,7 +70,7 @@ TEMPLATES = ( ...@@ -65,7 +70,7 @@ TEMPLATES = (
'debug': DEBUG, 'debug': DEBUG,
}, },
}, },
) ]
WSGI_APPLICATION = '{{ project_name }}.wsgi.application' WSGI_APPLICATION = '{{ project_name }}.wsgi.application'
...@@ -80,7 +85,7 @@ DATABASES = { ...@@ -80,7 +85,7 @@ DATABASES = {
} }
} }
AUTH_PASSWORD_VALIDATORS = ( AUTH_PASSWORD_VALIDATORS = [
{ {
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
}, },
...@@ -93,7 +98,7 @@ AUTH_PASSWORD_VALIDATORS = ( ...@@ -93,7 +98,7 @@ AUTH_PASSWORD_VALIDATORS = (
{ {
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
}, },
) ]
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/ # https://docs.djangoproject.com/en/1.9/topics/i18n/
...@@ -127,4 +132,4 @@ STATICFILES_DIRS = [ ...@@ -127,4 +132,4 @@ STATICFILES_DIRS = [
# Simplified static file serving. # Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/ # https://warehouse.python.org/project/whitenoise/
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
from django.conf.urls import include, url """{{ project_name }} URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/{{ docs_version }}/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin from django.contrib import admin
urlpatterns = [ urlpatterns = [
# Examples: url(r'^admin/', admin.site.urls),
# url(r'^$', '{{ project_name }}.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
] ]
...@@ -4,15 +4,13 @@ WSGI config for {{ project_name }} project. ...@@ -4,15 +4,13 @@ WSGI config for {{ project_name }} project.
It exposes the WSGI callable as a module-level variable named ``application``. It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see For more information on this file, see
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/
""" """
import os import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")
from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")
application = get_wsgi_application() application = get_wsgi_application()
application = DjangoWhiteNoise(application)
\ No newline at end of file
...@@ -2,4 +2,4 @@ dj-database-url==0.4.0 ...@@ -2,4 +2,4 @@ dj-database-url==0.4.0
Django==1.9.2 Django==1.9.2
gunicorn==19.4.5 gunicorn==19.4.5
psycopg2==2.6.1 psycopg2==2.6.1
whitenoise==2.0.6 whitenoise==3.2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment