Skip to content

Instantly share code, notes, and snippets.

@a-musing-moose
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a-musing-moose/8793439 to your computer and use it in GitHub Desktop.
Save a-musing-moose/8793439 to your computer and use it in GitHub Desktop.
S3 static and media storage
# S3 config to separate media and static roots
from storages.backends.s3boto import S3BotoStorage
StaticRootS3BotoStorage = lambda: S3BotoStorage(
location='static',
secure_urls=False,
)
MediaRootS3BotoStorage = lambda: S3BotoStorage(
location='media',
secure_urls=False
)
# S3 Storage settings
AWS_ACCESS_KEY_ID = 'I have the secret'
AWS_SECRET_ACCESS_KEY = 'secrets should be kept that way'
AWS_STORAGE_BUCKET_NAME = 'dear-liza'
# Django Storages/S3 Settings
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
DEFAULT_FILE_STORAGE = 's3utils.MediaRootS3BotoStorage'
STATICFILES_STORAGE = 's3utils.StaticRootS3BotoStorage'
MEDIA_URL = "https://{}.s3-ap-southeast-2.amazonaws.com/media/".format(
AWS_STORAGE_BUCKET_NAME
)
STATIC_URL = "https://{}.s3-ap-southeast-2.amazonaws.com/static/".format(
AWS_STORAGE_BUCKET_NAME
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment