[英]Error importing static files from S3 Bucket Django
I tried uploading my static and media files onto AWS S3 bucket but, the css is not being rendered. 我尝试将静态文件和媒体文件上传到AWS S3存储桶,但是未渲染CSS。
settings.py
AWS_HEADERS = { # see http://developer.yahoo.com/performance /rules.html#expires
'Expires': 'Thu, 31 Dec 2099 20:00:00 GMT',
'Cache-Control': 'max-age=94608000',
}
AWS_STORAGE_BUCKET_NAME = '*'
AWS_ACCESS_KEY_ID = '*'
AWS_SECRET_ACCESS_KEY = '*'
AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
STATIC_URL = "https://%s/" % AWS_S3_CUSTOM_DOMAIN
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATICFILES_LOCATION = 'static'
STATICFILES_STORAGE = 'custom_storages.StaticStorage'
STATIC_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, STATICFILES_LOCATION)
MEDIAFILES_LOCATION = 'media'
MEDIA_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, MEDIAFILES_LOCATION)
DEFAULT_FILE_STORAGE = 'custom_storages.MediaStorage'
And when I try to access the css file through its source I get the following message - 当我尝试通过其源访问css文件时,收到以下消息-
<Error><Code>AccessDenied</Code><Message>Access Denied</Message>
<RequestId>BD606AFA0AF488B7</RequestId>
<HostId>2aZOfc5qdORtn2VhfDQsJ2gZHPoYBeBV9ciAdOnk+wGuK7azaWngXwfv+rEy1XLMFOrOgs+qDpI= </HostId>
</Error>
Sorry was making a silly mistake. 对不起,我犯了一个愚蠢的错误。 The root of the static folders was not specified in
STATICFILES_DIRS
so collectstatic
command couldn't collect those files. 静态文件夹的根未在
STATICFILES_DIRS
指定,因此collectstatic
命令无法收集这些文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.