Merge pull request #496 from cdvv7788/issues/254

Make sure that STATIC_URL != MEDIA_URL
This commit is contained in:
Jannis Gebauer 2016-03-08 10:04:33 +01:00
commit d78df9880d

View File

@ -97,7 +97,6 @@ INSTALLED_APPS += ("gunicorn", )
INSTALLED_APPS += ( INSTALLED_APPS += (
'storages', 'storages',
) )
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_ACCESS_KEY_ID = env('DJANGO_AWS_ACCESS_KEY_ID') AWS_ACCESS_KEY_ID = env('DJANGO_AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = env('DJANGO_AWS_SECRET_ACCESS_KEY') AWS_SECRET_ACCESS_KEY = env('DJANGO_AWS_SECRET_ACCESS_KEY')
@ -119,15 +118,25 @@ AWS_HEADERS = {
# URL that handles the media served from MEDIA_ROOT, used for managing # URL that handles the media served from MEDIA_ROOT, used for managing
# stored files. # stored files.
{% 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
{% else %}
# See:http://stackoverflow.com/questions/10390244/
from storages.backends.s3boto import S3BotoStorage
StaticRootS3BotoStorage = lambda: S3BotoStorage(location='static')
MediaRootS3BotoStorage = lambda: S3BotoStorage(location='media')
DEFAULT_FILE_STORAGE = 'config.settings.production.MediaRootS3BotoStorage'
MEDIA_URL = 'https://s3.amazonaws.com/%s/media/' % AWS_STORAGE_BUCKET_NAME
{%- endif %}
# Static Assets # Static Assets
# ------------------------ # ------------------------
{% if cookiecutter.use_whitenoise == 'y' -%} {% if cookiecutter.use_whitenoise == 'y' -%}
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
{% else %} {% else %}
STATICFILES_STORAGE = DEFAULT_FILE_STORAGE STATIC_URL = 'https://s3.amazonaws.com/%s/static/' % AWS_STORAGE_BUCKET_NAME
STATIC_URL = MEDIA_URL STATICFILES_STORAGE = 'config.settings.production.StaticRootS3BotoStorage'
# See: https://github.com/antonagestam/collectfast # See: https://github.com/antonagestam/collectfast
# For Django 1.7+, 'collectfast' should come before # For Django 1.7+, 'collectfast' should come before