Use django-storages for media files if using WhiteNoise - fixes #1192

As per the discussion in #869, WhiteNoise is for serving static files
not for media files (files uploaded from the app by users).
For such thing, we still need `DEFAULT_FILE_STORAGE` to be set and
we use django-storages for that.
This commit is contained in:
Bruno Alla 2017-08-02 20:10:49 +01:00
parent 12db5176d6
commit 4be48b7999

View File

@ -1,7 +1,9 @@
"""
Production Configurations
- Use Amazon's S3 for storing static files and uploaded media
{% if cookiecutter.use_whitenoise == 'y' -%}
- Use WhiteNoise for serving static files{% endif %}
- Use Amazon's S3 for {% if cookiecutter.use_whitenoise == 'n' -%}storing static files {% endif %}and uploaded media
- Use mailgun to send emails
- Use Redis for cache
{% if cookiecutter.use_sentry_for_error_reporting == 'y' %}
@ -113,6 +115,7 @@ AWS_HEADERS = {
# stored files.
{% if cookiecutter.use_whitenoise == 'y' -%}
MEDIA_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
{% else %}
# See:http://stackoverflow.com/questions/10390244/
from storages.backends.s3boto3 import S3Boto3Storage