使用Django,存储器和Django的COM pressor在一起的时候试图COM preSS静态文件时出错存储器、静态、时候、文件

2023-09-11 10:10:55 作者:↙妳永远不懂↗俄的心

我已经安装了AWS S3存储,以便使用应用程序Django的存储器传输在一个偏僻的CDN我的静态文件, 一切运行正常,直到我试图COM preSS我的静态文件使用上传到S3 django_com pressor。

I have setup an AWS S3 bucket in order to transfer my static files in a remote CDN using the application django-storages, everything worked fine until I tried to compress my static files before uploading to S3 using django_compressor.

我已经安装的所有变量根据django_com pressor文档Django的存储器(的https://django_com$p$pssor.readthedocs.org/en/latest/remote-storages/index.html)

I have setup all the variables according django_compressor documentation for django-storages (https://django_compressor.readthedocs.org/en/latest/remote-storages/index.html)

我上传的所有文件S3使用manage.py collectstatic',那么:

I uploaded all the files in S3 using 'manage.py collectstatic' then:

当我做'manage.py COM preSS'我得到这个错误:

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

有什么毛病我的设置?

What's wrong with my setup?

这是我的Django的存储器settings.py配置和django_com pressor:

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

感谢您的帮助

Thanks for your help

推荐答案

我固定它通过增加一个变量,它的工作:

I fixed it by adding one variable and it worked:

AWS_S3_CUSTOM_DOMAIN = 'my_bucket.s3-external-3.amazonaws.com'