don't use S3 to serve static assets for now, and serve them up using dj-static

This commit is contained in:
Nate Aune 2013-09-27 11:00:49 -04:00
parent d6acaedee0
commit 9dc2de4301

View File

@ -284,6 +284,13 @@ class Local(Common):
join(BASE_DIR, '..', 'static'), join(BASE_DIR, '..', 'static'),
) )
# as recommended on # https://devcenter.heroku.com/articles/django-assets
# PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
# STATICFILES_DIRS = (
# join(PROJECT_PATH, 'static'),
# )
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
STATICFILES_FINDERS = ( STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.FileSystemFinder',
@ -326,46 +333,63 @@ class Production(Common):
INSTALLED_APPS += ("gunicorn", ) INSTALLED_APPS += ("gunicorn", )
try: # serve static assets using S3 ########## STATIC FILE CONFIGURATION
# See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
AWS_ACCESS_KEY_ID = values.SecretValue() STATIC_ROOT = 'staticfiles'
AWS_SECRET_ACCESS_KEY = values.SecretValue()
AWS_STORAGE_BUCKET_NAME = values.SecretValue()
AWS_AUTO_CREATE_BUCKET = True
AWS_QUERYSTRING_AUTH = False
# AWS cache settings, don't change unless you know what you're doing: # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
AWS_EXPIREY = 60 * 60 * 24 * 7 STATIC_URL = '/static/'
AWS_HEADERS = {
'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
AWS_EXPIREY)
}
########## STORAGE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
# See: http://django-storages.readthedocs.org/en/latest/index.html STATICFILES_DIRS = (
INSTALLED_APPS += ( join(BASE_DIR, '..', 'static'),
'storages', )
)
# See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings # as recommended on # https://devcenter.heroku.com/articles/django-assets
STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' # PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url # STATICFILES_DIRS = (
STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME # join(PROJECT_PATH, 'static'),
# )
# TODO: check that this actually works # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
MEDIA_URL = 'https://s3.amazonaws.com/%s/media/' % AWS_STORAGE_BUCKET_NAME STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
# TODO: check to see if AWS keys are set and if they are, serve static assets using S3
# See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
# AWS_ACCESS_KEY_ID = values.SecretValue()
########## END STORAGE CONFIGURATION # AWS_SECRET_ACCESS_KEY = values.SecretValue()
except: # serve static assets using wsgi # AWS_STORAGE_BUCKET_NAME = values.SecretValue()
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) # AWS_AUTO_CREATE_BUCKET = True
STATIC_ROOT = 'staticfiles' # AWS_QUERYSTRING_AUTH = False
STATIC_URL = '/static/'
STATICFILES_DIRS = ( # # AWS cache settings, don't change unless you know what you're doing:
join(PROJECT_PATH, 'static'), # AWS_EXPIREY = 60 * 60 * 24 * 7
) # AWS_HEADERS = {
# 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
# AWS_EXPIREY)
# }
# ########## STORAGE CONFIGURATION
# # See: http://django-storages.readthedocs.org/en/latest/index.html
# INSTALLED_APPS += (
# 'storages',
# )
# # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
# STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
# # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
# STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
# # TODO: check that this actually works
# MEDIA_URL = 'https://s3.amazonaws.com/%s/media/' % AWS_STORAGE_BUCKET_NAME
########## END STORAGE CONFIGURATION
########## EMAIL ########## EMAIL
DEFAULT_FROM_EMAIL = values.Value( DEFAULT_FROM_EMAIL = values.Value(