我已经设置了一个 AWS S3 存储桶,以便使用应用程序 django-storages 在远程 CDN 中传输我的静态文件,一切正常,直到我尝试在使用 django_compressor 上传到 S3 之前压缩我的静态文件。
我已经根据 django-storages 的 django_compressor 文档设置了所有变量(https://django_compressor.readthedocs.org/en/latest/remote-storages/index.html)
我使用'manage.py collectstatic'上传了S3中的所有文件,然后:
当我执行“manage.py compress”时,我收到此错误:
CommandError: An error occured during rendering ../templates/base.html: 'https://my_bucket.s3.amazonaws.com/css/bootstrap.2.3.1.css' isn't accessible via COMPRESS_URL ('https://my_bucket.s3-external-3.amazonaws.com/') and can't be compressed
我的设置有什么问题?
这是我对 django-storages 和 django_compressor 的 settings.py 配置:
COMPRESS_URL = 'https://mybucket_name.s3-external-3.amazonaws.com/'
STATIC_URL = COMPRESS_URL
DEFAULT_FILE_STORAGE = 'my_project.boto_custom.CachedS3BotoStorage'
AWS_ACCESS_KEY_ID = 'XXX'
AWS_SECRET_ACCESS_KEY = 'XXX'
AWS_STORAGE_BUCKET_NAME = 'mybucket_name'
COMPRESS_ROOT = STATIC_ROOT
COMPRESS_STORAGE = 'my_project.boto_custom.CachedS3BotoStorage'
STATICFILES_STORAGE = 'my_project.boto_custom.CachedS3BotoStorage'
COMPRESS_OFFLINE = True
谢谢你的帮助