之前用django-ckeditor作富文本编辑器,想实现文章修改,不知道怎么网富文本编辑器中填充原有的文章。
然后用原生的ckeditor实现了。
1、下载ckeditor4到django静态文件夹
2、在更新文章的模板中或者base.html中引入ckeditor.js文件
<script src="{% static 'ckeditor4/ckeditor.js' %}"></script>
3、再次修改更新文章的模板文件,
<textarea type="text" class="form-control" id="body" name="body" rows="12">{{ article.body | safe }}</textarea>
<script>
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
CKEDITOR.replace( 'body' );
</script>
官方文档参考:
https://ckeditor.com/docs/ckeditor4/latest/guide/dev_installation.html#adding-ckeditor-to-your-page