我正在管理面板外部使用CKEditor。我想在自定义ckeditor/widget.html
中加载媒体,但无法正常工作。
这是我的“ ckeditor / widget.html”:
{% block css %}
{{ form.media }}
{% endblock %}
<div class="write_comment">
<div class="django-ckeditor-widget" data-field-id="{{ id }}">
<textarea{{ final_attrs }} data-processed="0" data-config="{{ config }}" data-external-plugin-resources="{{ external_plugin_resources }}" data-id="{{ id }}" data-type="ckeditortype">{{ value }}</textarea>
</div>
<div class="bottom">
<ul class="flex-horizontal">
<li><p class="chars_written"></p></li>
<li><p class="chars_left"></p></li>
</ul>
</div>
</div>
这是我的自定义小部件:
class CommentInput(CKEditorWidget):
@property
def media(self):
media = super().media
css = {
"all": (
static("widgets/comment/comment.js"),
)
}
js = [
static("widgets/comment/comment.css"),
]
media.add_css(css)
media.add_js(js)
print(media)
return media