django中xadmin中对应ueditor包的下载与安装教程-版本(python3.6.9,xadmin2.2)

效果图:

1. ueditor源码下载链接:

https://pan.baidu.com/s/12TLhVRb_PXu5k4_NtOJOMw 

链接:https://pan.baidu.com/s/12TLhVRb_PXu5k4_NtOJOMw 
提取码:da3h 

2. 将djangoueditor源码拷贝到项目根目录下
3. INSTALLED_APPS 中配置 'DjangoUeditor'
4. 配置相关的url:
    url(r'^u editor/',include('DjangoUeditor.urls')),

5. 下载ueditor插件并放置到xadmin源码的plugins目录下

ueditor插件下载链接:https://pan.baidu.com/s/11z3pUIrLV_yUmTqgNSt3pw

链接:https://pan.baidu.com/s/11z3pUIrLV_yUmTqgNSt3pw 
提取码:hpau 

6. 将editor文件名配置到plugins目录下的__init__.py文件的PLUGINS变量中

7. 修改模型类中的富文本字段

配置参考网址:https://github.com/zhangfisher/DjangoUeditor

from DjangoUeditor.models import UEditorField

class Course(BaseModel):
    name = models.CharField(max_length=50, verbose_name="课程名")
    detail = UEditorField(verbose_name="课程详情", width=600, height=300, default="",
                          imagePath="courses/ueditor/images/",
                          filePath="courses/ueditor/files/")

8. 在对应的model模型管理类中配置:

增加style_fields属性 = {"字段名": "ueditor"}

class CourseAdmin(object):
    list_display = ["name", "desc", "detail", "degree", "learn_times", "students", "show_image", "goto_course"]

    # 富文本ueditor配置
    style_fields = {"detail": "ueditor"}

xadmin.site.register(Course, CourseAdmin)

猜你喜欢

转载自blog.csdn.net/weixin_42289273/article/details/115177127