Merge pull request #1269 from browniebroke/patch-1

Update django-storages and Boto3 fixes #998 & #1192
This commit is contained in:
Fábio C. Barrionuevo da Luz 2017-08-23 14:17:02 -03:00 committed by GitHub
commit 09ecda33b3
3 changed files with 13 additions and 10 deletions

View File

@ -63,7 +63,8 @@ Listed in alphabetical order.
Bo Lopker `@blopker`_ Bo Lopker `@blopker`_
Bouke Haarsma Bouke Haarsma
Brent Payne `@brentpayne`_ @brentpayne Brent Payne `@brentpayne`_ @brentpayne
Burhan Khalid `@burhan`_ @burhan Bruno Alla               `@browniebroke`_ @_BrunoAlla
Burhan Khalid            `@burhan`_                   @burhan
Catherine Devlin `@catherinedevlin`_ Catherine Devlin `@catherinedevlin`_
Cédric Gaspoz `@cgaspoz`_ Cédric Gaspoz `@cgaspoz`_
Chris Curvey `@ccurvey`_ Chris Curvey `@ccurvey`_
@ -165,6 +166,7 @@ Listed in alphabetical order.
.. _@bloodpet: https://github.com/bloodpet .. _@bloodpet: https://github.com/bloodpet
.. _@blopker: https://github.com/blopker .. _@blopker: https://github.com/blopker
.. _@bogdal: https://github.com/bogdal .. _@bogdal: https://github.com/bogdal
.. _@browniebroke: https://github.com/browniebroke
.. _@burhan: https://github.com/burhan .. _@burhan: https://github.com/burhan
.. _@c-rhodes: https://github.com/c-rhodes .. _@c-rhodes: https://github.com/c-rhodes
.. _@caffodian: https://github.com/caffodian .. _@caffodian: https://github.com/caffodian

View File

@ -1,7 +1,9 @@
""" """
Production Configurations 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 mailgun to send emails
- Use Redis for cache - Use Redis for cache
{% if cookiecutter.use_sentry_for_error_reporting == 'y' %} {% if cookiecutter.use_sentry_for_error_reporting == 'y' %}
@ -12,7 +14,6 @@ Production Configurations
{% endif %} {% endif %}
""" """
from boto.s3.connection import OrdinaryCallingFormat
{% if cookiecutter.use_sentry_for_error_reporting == 'y' %} {% if cookiecutter.use_sentry_for_error_reporting == 'y' %}
import logging import logging
{% endif %} {% endif %}
@ -98,7 +99,6 @@ AWS_SECRET_ACCESS_KEY = env('DJANGO_AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = env('DJANGO_AWS_STORAGE_BUCKET_NAME') AWS_STORAGE_BUCKET_NAME = env('DJANGO_AWS_STORAGE_BUCKET_NAME')
AWS_AUTO_CREATE_BUCKET = True AWS_AUTO_CREATE_BUCKET = True
AWS_QUERYSTRING_AUTH = False AWS_QUERYSTRING_AUTH = False
AWS_S3_CALLING_FORMAT = OrdinaryCallingFormat()
# AWS cache settings, don't change unless you know what you're doing: # AWS cache settings, don't change unless you know what you're doing:
AWS_EXPIRY = 60 * 60 * 24 * 7 AWS_EXPIRY = 60 * 60 * 24 * 7
@ -115,11 +115,12 @@ AWS_HEADERS = {
# stored files. # stored files.
{% if cookiecutter.use_whitenoise == 'y' -%} {% if cookiecutter.use_whitenoise == 'y' -%}
MEDIA_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME MEDIA_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
{% else %} {% else %}
# See:http://stackoverflow.com/questions/10390244/ # See:http://stackoverflow.com/questions/10390244/
from storages.backends.s3boto import S3BotoStorage from storages.backends.s3boto3 import S3Boto3Storage
StaticRootS3BotoStorage = lambda: S3BotoStorage(location='static') StaticRootS3BotoStorage = lambda: S3Boto3Storage(location='static')
MediaRootS3BotoStorage = lambda: S3BotoStorage(location='media') MediaRootS3BotoStorage = lambda: S3Boto3Storage(location='media')
DEFAULT_FILE_STORAGE = 'config.settings.production.MediaRootS3BotoStorage' DEFAULT_FILE_STORAGE = 'config.settings.production.MediaRootS3BotoStorage'
MEDIA_URL = 'https://s3.amazonaws.com/%s/media/' % AWS_STORAGE_BUCKET_NAME MEDIA_URL = 'https://s3.amazonaws.com/%s/media/' % AWS_STORAGE_BUCKET_NAME
@ -141,7 +142,7 @@ INSTALLED_APPS = ['collectfast', ] + INSTALLED_APPS
{% if cookiecutter.use_compressor == 'y'-%} {% if cookiecutter.use_compressor == 'y'-%}
# COMPRESSOR # COMPRESSOR
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
COMPRESS_STORAGE = 'storages.backends.s3boto.S3BotoStorage' COMPRESS_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
COMPRESS_URL = STATIC_URL COMPRESS_URL = STATIC_URL
COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True) COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True)
{%- endif %} {%- endif %}

View File

@ -16,8 +16,8 @@ gunicorn==19.7.1
# Static and Media Storage # Static and Media Storage
# ------------------------------------------------ # ------------------------------------------------
boto==2.48.0 boto3==1.4.5
django-storages-redux==1.3.3 django-storages==1.6.5
{% if cookiecutter.use_whitenoise != 'y' -%} {% if cookiecutter.use_whitenoise != 'y' -%}
Collectfast==0.5.2 Collectfast==0.5.2
{%- endif %} {%- endif %}