django使用富文本应用DjangoUeditor

1.python3: https://github.com/twz915/DjangoUeditor3/ (直接下载zip)

   python2:https://github.com/zhangfisher/DjangoUeditor(直接下载zip)

2. 解压得到的文件夹为django使用富文本应用DjangoUeditor

3.把这个文件夹中的DjangoUeditor提取出来django使用富文本应用DjangoUeditor 

4,把DjangoUeditor当作我们项目的应用,并放到项目的根目录处

django使用富文本应用DjangoUeditor

5,在setting加入DjangoUeditor应用,并且加入上传图片时的路径设置
django使用富文本应用DjangoUeditordjango使用富文本应用DjangoUeditor

6,在项目的url.py里面加入应用的路径和图片的上传的路径,如图中的红框:

django使用富文本应用DjangoUeditor

7,到DjangoUeditor应用下 的form.py,修改引入方式,不然会报错,修改成如下红框

django使用富文本应用DjangoUeditor

8,在mytest(也就是要用富文本编辑器的应用)的models.py里添加编辑字段

django使用富文本应用DjangoUeditor

9,执行python3 manage.py makemigrations 和python3 manage.py migrate

10,在admin.py注册 

 django使用富文本应用DjangoUeditor

11,到后台添加一个数据

django使用富文本应用DjangoUeditor

12,在视图函数里面引用编辑框和要显示的数据

django使用富文本应用DjangoUeditor

13,在前端显示编辑框和要显示的数据

django使用富文本应用DjangoUeditor

14,刷新网页,显示成功。

django使用富文本应用DjangoUeditor

 

15,读写值:

获取纯文本:UE.getEditor('id_content').getPlainTxt()

获取原始值:UE.getEditor('id_content').getContent()

写入值:UE.getEditor('id_content').setContent("<h1>test</h1>")