Skip to content

Instantly share code, notes, and snippets.

@ozorest

ozorest/settings.py

Created Aug 31, 2020
Embed
What would you like to do?
Example settings.py for use S3
# Use S3 for static content
AWS_ACCESS_KEY_ID = env('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = env('AWS_SECRET_ACCESS_KEY')
AWS_S3_BUCKET_NAME = "example-static-bucket"
AWS_S3_BUCKET_NAME_STATIC = AWS_S3_BUCKET_NAME
AWS_S3_KEY_PREFIX = "media"
AWS_S3_KEY_PREFIX_STATIC = "static"
AWS_REGION = env('AWS_REGION')
AWS_S3_CUSTOM_DOMAIN = f'{AWS_S3_BUCKET_NAME}.s3.amazonaws.com'
STATIC_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/static/'
STATICFILES_STORAGE = 'django_s3_storage.storage.StaticS3Storage'
PUBLIC_MEDIA_LOCATION = 'media'
MEDIA_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/{PUBLIC_MEDIA_LOCATION}/'
DEFAULT_FILE_STORAGE = 'django_s3_storage.storage.S3Storage'
# Use S3 for SQLite database
DATABASES = {
'default': {
'ENGINE': 'django_s3_sqlite',
'NAME': "data.db",
'BUCKET': "example_bucket",
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment