mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-22 09:36:52 +03:00
Updated whitenoise configuration to match changes in version 3.0
(see http://whitenoise.evans.io/en/stable/changelog.html)
This commit is contained in:
parent
4d110c8ad9
commit
3c6898b3f6
|
@ -44,17 +44,23 @@ INSTALLED_APPS += ('raven.contrib.django.raven_compat', )
|
|||
SECURITY_MIDDLEWARE = (
|
||||
'djangosecure.middleware.SecurityMiddleware',
|
||||
)
|
||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||
# Use Whitenoise to serve static files
|
||||
# See: https://whitenoise.readthedocs.org/
|
||||
WHITENOISE_MIDDLEWARE = (
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
)
|
||||
MIDDLEWARE_CLASSES = WHITENOISE_MIDDLEWARE + MIDDLEWARE_CLASSES
|
||||
{%- endif %}
|
||||
{% if cookiecutter.use_sentry == 'y' -%}
|
||||
RAVEN_MIDDLEWARE = ('raven.contrib.django.raven_compat.middleware.Sentry404CatchMiddleware',
|
||||
'raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware',)
|
||||
MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + \
|
||||
RAVEN_MIDDLEWARE + MIDDLEWARE_CLASSES
|
||||
{% else %}
|
||||
MIDDLEWARE_CLASSES = RAVEN_MIDDLEWARE + MIDDLEWARE_CLASSES
|
||||
{%- endif %}
|
||||
|
||||
# Make sure djangosecure.middleware.SecurityMiddleware is listed first
|
||||
MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + MIDDLEWARE_CLASSES
|
||||
|
||||
{%- endif %}
|
||||
{% if cookiecutter.use_opbeat == 'y' -%}
|
||||
# opbeat integration
|
||||
# See https://opbeat.com/languages/django/
|
||||
|
@ -132,7 +138,7 @@ MEDIA_URL = 'https://s3.amazonaws.com/%s/media/' % AWS_STORAGE_BUCKET_NAME
|
|||
# Static Assets
|
||||
# ------------------------
|
||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
|
||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||
{% else %}
|
||||
STATIC_URL = 'https://s3.amazonaws.com/%s/static/' % AWS_STORAGE_BUCKET_NAME
|
||||
STATICFILES_STORAGE = 'config.settings.production.StaticRootS3BotoStorage'
|
||||
|
|
|
@ -21,9 +21,6 @@ if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
|
|||
newrelic.agent.initialize()
|
||||
{%- endif %}
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||
from whitenoise.django import DjangoWhiteNoise
|
||||
{%- endif %}
|
||||
{% if cookiecutter.use_sentry == 'y' -%}
|
||||
if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
|
||||
from raven.contrib.django.raven_compat.middleware.wsgi import Sentry
|
||||
|
@ -39,12 +36,6 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
|
|||
# file. This includes Django's development server, if the WSGI_APPLICATION
|
||||
# setting points here.
|
||||
application = get_wsgi_application()
|
||||
|
||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||
# Use Whitenoise to serve static files
|
||||
# See: https://whitenoise.readthedocs.org/
|
||||
application = DjangoWhiteNoise(application)
|
||||
{%- endif %}
|
||||
{% if cookiecutter.use_sentry == 'y' -%}
|
||||
if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
|
||||
application = Sentry(application)
|
||||
|
|
Loading…
Reference in New Issue
Block a user