使用 Amazon S3 静态存储进行静态加载的 django-cms_text_ckeditor 错误

Posted

技术标签:

【中文标题】使用 Amazon S3 静态存储进行静态加载的 django-cms_text_ckeditor 错误【英文标题】:django-cms_text_ckeditor error of static loading with Amazon S3 static storage 【发布时间】:2019-01-03 10:15:03 【问题描述】:

使用 amazon S3 在服务器上部署 django + django-cms 项目后 (STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' ),没有为 django-cms_text_ckeditor 加载静态文件,ckeditor 包正在尝试从本地存储加载静态文件,但它不起作用, 明显地。所有其他静态文件都从 s3 存储桶加载,没有任何问题。在 localhost ckeditor 捆绑包正在请求本地静态文件,并且它正在工作,其他静态文件从 s3 存储桶加载。 也许有人知道如何使用 s3 使捆绑加载静态,或者只是从项目服务器获取文件(如 localhost 行为)?此插件仅在管理员中使用,因此使用它加载服务器静态并不重要。

不适用于 ckeditor 默认设置,如自定义设置和从 ckeditor 官方网站加载的包。

谷歌显然没有成功,虽然我花了很多时间。

Django==1.11.13 django-cms_text_ckeditor==3.6.0

Loading failed for the <script> with source “http://myproject.herokuapp.com/static/cms_modules/ckeditor/config.js?t=G87E”. config:1
Loading failed for the <script> with source “http://myproject.herokuapp.com/static/cms_modules/ckeditor/skins/moonocolor/skin.js?t=G87E”. config:1
Loading failed for the <script> with source “http://myproject.herokuapp.com/static/cms_modules/ckeditor/lang/en.js?t=G87E”. config:1
TypeError: c[a] is undefined

【问题讨论】:

【参考方案1】:

如果有人对此感兴趣,请通过以下方式解决:

AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME', 'example-app')
AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
TEXT_CKEDITOR_BASE_PATH = 'https://%s/djangocms_text_ckeditor/ckeditor/' % AWS_S3_CUSTOM_DOMAIN

【讨论】:

以上是关于使用 Amazon S3 静态存储进行静态加载的 django-cms_text_ckeditor 错误的主要内容,如果未能解决你的问题,请参考以下文章

图像未从 Amazon S3 存储桶加载

为啥托管静态网站时 Amazon S3 存储桶名称必须与网站名称相同

从静态网页上传 csv 文件到 S3 存储桶

将 Amazon S3 存储桶和 Cloudfront 与 SSL Wordpress 站点一起使用不会提供静态文件

Amazon s3 静态 Web 托管缓存

用于收集静态的 Django 1.11 + Amazon S3