我对django-ckeditor
有问题,我正在django-pipeline
使用它,在本地运行时一切都可以,但是如果DEBUG=False
ckeditor.js使用的就是压缩的并且失败。
这是我在加载管理员以呈现使用 django-ckeditor 的字段时从 chrome 中的开发人员工具中得到的问题
ckeditor.8e9749424093.js:245
Uncaught TypeError: Cannot set property 'dir' of undefined
at Object.d (ckeditor.8e9749424093.js:245)
at f (ckeditor.8e9749424093.js:246)
at Array.C (ckeditor.8e9749424093.js:246)
at w (ckeditor.8e9749424093.js:246)
at ckeditor.8e9749424093.js:247```
该文件存在并已加载,但出现问题,似乎管道的压缩破坏了它。
我已经用谷歌搜索了这个问题,我找到的唯一建议来自文档。我还将此代码添加到模板中,以确保测试所有可能的解决方案,但没有任何变化。
{% extends "admin/base_site.html" %}
{% block extrahead %}
<script>window.CKEDITOR_BASEPATH = '/static/ckeditor/ckeditor/' </script>
{{ block.super }}
{% endblock %}
有什么建议吗?
你走在正确的轨道上,如下所述:https://github.com/django-ckeditor/django-ckeditor/blob/master/README.rst#id2
你需要在 Django 模板中以正确的顺序放置 JS 资产。
以下为我解决了它:
{% block extrahead %}
{{ block.super }}
{# CKEditor needs to know where its assets are located #}
<script>window.CKEDITOR_BASEPATH = '/static/ckeditor/ckeditor/';</script>
<script type="text/javascript" src="{% static "ckeditor/ckeditor-init.js" %}"></script>
<script type="text/javascript" src="{% static "ckeditor/ckeditor/ckeditor.js" %}"></script>
{% endblock %}