本文详解如何在 django 项目中(使用 django-ckeditor 6.7.0)永久关闭 ckeditor 4.22.1+ 版本引入的“此版本不安全,请升级”红色通知栏,通过正确配置 `config.versioncheck = false` 实现静默禁用。
CKEditor 4 自 4.22.0 版本起新增了主动版本检查机制,会在编辑器加载时向官方 CDN 发起请求(如 https://cdn.ckeditor.com/.../version.json),比对本地版本与最新 LTS 版本,并在顶部显示醒目的黄色/红色警告条:“This CKEditor X.X.X version is not secure. Consider upgrading…”。该行为不受 CKEDITOR_UPDATE_NOTIFICATION = False 或 ignoreUpdates: true 等旧参数控制——因为这些并非 CKEditor 4 原生配置项,而是某些第三方封装(如早期 django-ckeditor 插件)的自定义开关,在新版中已失效。
✅ 正确解决方案是:在 CKEditor 的 JavaScript 运行时配置中显式设置 config.versionCheck = false。由于你使用的是 django-ckeditor,需将其注入到 CKEDITOR_CONFIGS 的顶层配置对象中(注意:不是嵌套在 t

请修改 settings.py 中的 CKEDITOR_CONFIGS,在 "default" 配置的最外层添加 'versionCheck': False(注意:django-ckeditor 会自动将 Python False 转为 JS false):
CKEDITOR_CONFIGS = {
"default": {
"skin": "moono",
"toolbar": "Custom",
"allowedContent": True,
"extraAllowedContent": "object[id,name,width,height];",
"extraPlugins": "iframe",
"iframe_attributes": {
"sandbox": "allow-scripts allow-same-origin allow-popups allow-presentation allow-forms",
"allowfullscreen": "",
"loading": "lazy",
"referrerpolicy": "no-referrer-when-downgrade",
},
# ? 关键修复:禁用版本检查(必须放在顶层!)
"versionCheck": False,
"toolbar_Custom": [
# ...(保持原有 toolbar 配置不变)
],
"language": "en",
}
}⚠️ 注意事项:
完成上述配置后重启 Django 开发服务器,进入 Admin 后的 RichTextUploadingField 将不再显示任何版本警告,编辑器功能与样式保持完全一致。该方案简洁、兼容性强,是当前社区验证有效的标准解法。