mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-29 13:04:05 +03:00
Merge pull request #227 from pydanny/whitenoise-support
feat(static_storage): Add support for whitenoise (optional)
This commit is contained in:
commit
91eb30da8c
|
@ -31,6 +31,7 @@ Features
|
|||
* Grunt build for compass and livereload
|
||||
* Basic e-mail configurations for send emails via SendGrid_
|
||||
* Media storage using Amazon S3
|
||||
* Serve static files from Amazon S3 or Whitenoise_ (optional)
|
||||
|
||||
.. _Bootstrap: https://github.com/twbs/bootstrap
|
||||
.. _AngularJS: https://github.com/angular/angular.js
|
||||
|
@ -40,6 +41,7 @@ Features
|
|||
.. _django-avatar: https://github.com/jezdez/django-avatar/
|
||||
.. _Procfile: https://devcenter.heroku.com/articles/procfile
|
||||
.. _SendGrid: https://sendgrid.com/
|
||||
.. _Whitenoise: https://whitenoise.readthedocs.org/
|
||||
|
||||
|
||||
Constraints
|
||||
|
|
|
@ -8,5 +8,6 @@
|
|||
"version": "0.1.0",
|
||||
"timezone": "UTC",
|
||||
"now": "2015/01/13",
|
||||
"year": "{{ cookiecutter.now[:4] }}"
|
||||
"year": "{{ cookiecutter.now[:4] }}",
|
||||
"use_whitenoise": "y"
|
||||
}
|
||||
|
|
|
@ -55,12 +55,13 @@ INSTALLED_APPS += ("gunicorn", )
|
|||
|
||||
# STORAGE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# Uploaded Media Files
|
||||
# ------------------------
|
||||
# See: http://django-storages.readthedocs.org/en/latest/index.html
|
||||
INSTALLED_APPS += (
|
||||
'storages',
|
||||
)
|
||||
|
||||
STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
|
||||
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
|
||||
|
||||
AWS_ACCESS_KEY_ID = env('DJANGO_AWS_ACCESS_KEY_ID')
|
||||
AWS_SECRET_ACCESS_KEY = env('DJANGO_AWS_SECRET_ACCESS_KEY')
|
||||
|
@ -69,11 +70,6 @@ AWS_AUTO_CREATE_BUCKET = True
|
|||
AWS_QUERYSTRING_AUTH = False
|
||||
AWS_S3_CALLING_FORMAT = OrdinaryCallingFormat()
|
||||
|
||||
# See: https://github.com/antonagestam/collectfast
|
||||
# For Django 1.7+, 'collectfast' should come before 'django.contrib.staticfiles'
|
||||
AWS_PRELOAD_METADATA = True
|
||||
INSTALLED_APPS = ('collectfast', ) + INSTALLED_APPS
|
||||
|
||||
# AWS cache settings, don't change unless you know what you're doing:
|
||||
AWS_EXPIRY = 60 * 60 * 24 * 7
|
||||
|
||||
|
@ -85,8 +81,22 @@ AWS_HEADERS = {
|
|||
AWS_EXPIRY, AWS_EXPIRY))
|
||||
}
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
|
||||
STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
|
||||
# URL that handles the media served from MEDIA_ROOT, used for managing stored files.
|
||||
MEDIA_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
|
||||
|
||||
# Static Assests
|
||||
# ------------------------
|
||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
|
||||
{% else %}
|
||||
STATICFILES_STORAGE = DEFAULT_FILE_STORAGE
|
||||
STATIC_URL = MEDIA_URL
|
||||
|
||||
# See: https://github.com/antonagestam/collectfast
|
||||
# For Django 1.7+, 'collectfast' should come before 'django.contrib.staticfiles'
|
||||
AWS_PRELOAD_METADATA = True
|
||||
INSTALLED_APPS = ('collectfast', ) + INSTALLED_APPS
|
||||
{%- endif %}
|
||||
|
||||
# EMAIL
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -15,6 +15,11 @@ framework.
|
|||
"""
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||
from whitenoise.django import DjangoWhiteNoise
|
||||
{%- endif %}
|
||||
|
||||
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
|
||||
# if running multiple sites in the same mod_wsgi process. To fix this, use
|
||||
# mod_wsgi daemon mode with each site in its own daemon process, or use
|
||||
|
@ -24,9 +29,14 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
|
|||
# This application object is used by any WSGI server configured to use this
|
||||
# file. This includes Django's development server, if the WSGI_APPLICATION
|
||||
# setting points here.
|
||||
from django.core.wsgi import get_wsgi_application # noqa
|
||||
application = get_wsgi_application()
|
||||
|
||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||
# Use Whitenoise to serve static files
|
||||
# See: https://whitenoise.readthedocs.org/
|
||||
application = DjangoWhiteNoise(application)
|
||||
{%- endif %}
|
||||
|
||||
# Apply WSGI middleware here.
|
||||
# from helloworld.wsgi import HelloWorldApplication
|
||||
# application = HelloWorldApplication(application)
|
||||
|
|
|
@ -2,8 +2,17 @@
|
|||
# production that isn't in development.
|
||||
-r base.txt
|
||||
|
||||
gunicorn==19.3.0
|
||||
django-storages-redux==1.2.3
|
||||
Collectfast==0.2.3
|
||||
# WSGI Handler
|
||||
# ------------------------------------------------
|
||||
gevent==1.0.1
|
||||
gunicorn==19.3.0
|
||||
|
||||
# Static and Media Storage
|
||||
# ------------------------------------------------
|
||||
boto==2.38.0
|
||||
django-storages-redux==1.2.3
|
||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||
whitenoise==1.0.6
|
||||
{% else %}
|
||||
Collectfast==0.2.3
|
||||
{%- endif %}
|
||||
|
|
Loading…
Reference in New Issue
Block a user