Skip to content

Instantly share code, notes, and snippets.

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 GoodnessEzeokafor/23d6284955477fe0cfb371fd29546611 to your computer and use it in GitHub Desktop.
Save GoodnessEzeokafor/23d6284955477fe0cfb371fd29546611 to your computer and use it in GitHub Desktop.
Adding S3 to your project

AWS CREDENTIAL

  • AWS_ACCESS_KEY_ID = ''

  • AWS_SECRET_ACCESS_KEY = ''

  • AWS_STORAGE_BUCKET_NAME = ''

  • AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME

  • AWS_S3_OBJECT_PARAMETERS = { 'CacheControl': 'max-age=86400', }

  • AWS_LOCATION = 'static'

  • MEDIA_URL = '%s.s3.amazonaws.com/media/' % AWS_STORAGE_BUCKET_NAME

  • MEDIA_ROOT = MEDIA_URL

  • AWS_DEFAULT_ACL = None

STATICFILES_DIRS = [

os.path.join(BASE_DIR, 'mysite/static'),

]

  • STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), ]

STATICFILES_DIRS = [

os.path.join(BASE_DIR, 'mysite/static'),

]

  • STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION)
  • ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'
  • STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

AWS_PUBLIC_MEDIA_LOCATION = 'media/public'

  • DEFAULT_FILE_STORAGE = 'mysite.storage_backends.MediaStorage'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment