在将django-storage和django-compressor一起使用时尝试压缩静态文件时出错

Oms*_*Oms 3 python django amazon-s3 django-storage django-compressor

我已经设置了一个AWS S3存储桶,以便使用应用程序django-storage在远程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
Run Code Online (Sandbox Code Playgroud)

我的设置有什么问题?

这是我的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
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助

Oms*_*Oms 7

我通过添加一个变量修复它,它工作:

AWS_S3_CUSTOM_DOMAIN = 'my_bucket.s3-external-3.amazonaws.com'
Run Code Online (Sandbox Code Playgroud)