小编Oms*_*Oms的帖子

在将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)

谢谢你的帮助

python django amazon-s3 django-storage django-compressor

3
推荐指数
1
解决办法
1940
查看次数

向 django 添加自定义语言

我正在将我的网站翻译成欧盟的 24 种语言。其中包括“Malti”语言,该语言未在 django 默认支持的语言中列出。

我想知道是否有一种方法可以向 django 添加自定义语言,以便它可以与本机 i18n url 函数一起使用。

谢谢!

python django multilingual

2
推荐指数
1
解决办法
1953
查看次数