django利用ckeditor富文本编辑器实现修改文章

之前用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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值