filmov
tv
Django Deployment Part 2 - Integration of Django with AWS S3 Bucket-Storage to serve static files.
![preview_player](https://i.ytimg.com/vi/15d6jdniYN8/maxresdefault.jpg)
Показать описание
In this second video, we will be covering how to remove internal server error. Then we go through adding S3 bucket in our Django project to serve static files.
Obtain YOUR_ACCESS_TOKEN and YOUR_SECRET_TOKEN from AWS S3 Tokens settings or from digital ocean spaces configuration.
_______________________________________________________________________________________
Installations required:
pip3 install django-storages boto3
_______________________________________________________________________________________
STATIC_URL = '/static/'
STATICFILES_DIRS = [
]
MEDIA_URL = '/media/'
# buckets settings
AWS_ACCESS_KEY_ID = 'YOUR_ACCESS_TOKEN'
AWS_SECRET_ACCESS_KEY = 'YOUR_SECRET_TOKEN'
AWS_STORAGE_BUCKET_NAME = 'YOUR_SPACE_NAME'
AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
}
AWS_LOCATION = 'static'
DEFAULT_FILE_STORAGE = 'YOUR_DJANGO_PROJECT.utils.MediaRootS3BotoStorage'
STATICFILES_STORAGE = 'YOUR_DJANGO_PROJECT.utils.StaticRootS3BotoStorage'
_______________________________________________________________________________________
StaticRootS3BotoStorage = lambda: S3Boto3Storage(location='static')
MediaRootS3BotoStorage = lambda: S3Boto3Storage(location='media')
_______________________________________________________________________________________
In last step:
Now your static files will be served from digital ocean spaces.
Комментарии