xadmin集成DjangoUeditor

1、安装

 安装DjangoUeditor

  1)去GitHub上面下载djangoueditor源码包(https://github.com/twz915/DjangoUeditor3)

     然后进入源码的setup.py所在目录,执行pyton setup.py install安装。

  2)直接通过pip命令安装

    pip install DjangoUeditor

 然后将DjangoUeditor放到settings文件的INSTALLED_APPS中

2、配置url

  url(r"^ueditor/", include(DjangoUeditor.urls))

3、在model中使用

  from DjangoUeditor.models import UEditorField

  field = UEditorField(verbose_name = "", width=200, height=300, imagepath="", filepath="", default="", toolbar=[[]])

  常用参数说明:

    verbose_name:字段显示名

    width/height:富文本宽高

    imagepath/filepath:图片/文件存储相对路径(相对settings中配置的MEDIA_ROOT)

    toolbar:工具栏上的功能按钮,注意这里的toolbar是嵌套的列表

4、准备工作都做好了,接下来需要在xadmin中集成调用,集成方法:

  在xadmin--->plugin中新建ueditor.py(名字自定义),内容如下:

    

  然后在xadmin--->plugin--->__init__.py文件的PLUGINS中加入我们自定义的插件ueditor

    

  这样就完成了ueditor在xadmin中的集成

  最后,在注册modelXadmin的中,加入style_fields={"字段名":"ueditor"}

  

猜你喜欢

转载自www.cnblogs.com/fiona-zhong/p/10233697.html
今日推荐