第一步,下载ueditor,在git上下载

直接download

: https://github.com/twz915/DjangoUeditor3/

然后放到任何一个文件夹里面

配置setting and urls

INSTALLED_APPS = [
'DjangoUeditor',
] #在工程里面新建 media的文件上传目录
MEDIA_URL ='/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
#urls里面配置
from extra_apps.DjangoUeditor import  urls as DjangoUeditor_urls urlpatterns = [
    path('ueditor/', include(DjangoUeditor_urls)),
]

然后改app里面的model,

text = UEditorField(verbose_name='文本记录',width=600, height=400,imagePath='user/ueditor/',filePath='user/ueditor/',default='')

然后在adminx.py里面写下调用类型

style_fields = {'text':'ueditor'}

然后在adminx的plugin写ueditor插件

import xadmin
from xadmin.views import BaseAdminPlugin, CreateAdminView, ModelFormAdminView, UpdateAdminView
from DjangoUeditor.models import UEditorField
from DjangoUeditor.widgets import UEditorWidget
from django.conf import settings class XadminUEditorWidget(UEditorWidget):
    def __init__(self,**kwargs):
        self.ueditor_options=kwargs
        self.Media.js = None
        super(XadminUEditorWidget,self).__init__(kwargs) class UeditorPlugin(BaseAdminPlugin):     def get_field_style(self, attrs, db_field, style, **kwargs):
        if style == 'ueditor':
            if isinstance(db_field, UEditorField):
                widget = db_field.formfield().widget
                param = {}
                param.update(widget.ueditor_settings)
                param.update(widget.attrs)
                return {'widget': XadminUEditorWidget(**param)}
        return attrs     def block_extrahead(self, context, nodes):
        js = '<script type="text/javascript" src="%s"></script>' % (settings.STATIC_URL + "ueditor/ueditor.config.js")         #自己的静态目录
        js += '<script type="text/javascript" src="%s"></script>' % (settings.STATIC_URL + "ueditor/ueditor.all.min.js")   #自己的静态目录
        nodes.append(js) xadmin.site.register_plugin(UeditorPlugin, UpdateAdminView)
xadmin.site.register_plugin(UeditorPlugin, CreateAdminView)

在plugins里面的_init_.py里面配置好 ueditor

PLUGINS = (
'ueditor'
)

ok

如果不出意外,应该已经生效了。可以调用了

https://www.cnblogs.com/tiantianhappy/p/10286528.html

在python3里面使用ueditor(基于adminx)的更多相关文章

  1. Caffe+VS2015+python3的安装(基于windows)

    在网上找了许多安装Caffe的教程 感觉全都是杂乱无章的 而且也没有详细的 只能自己当小白鼠来实验一次了 本次配置:CUDA 8.0+ CUDNN  +VS 2015 +Python 3.5 + Ca ...

  2. python3 Django集成Ueditor富文本编辑器

    1.下载 python3: https://github.com/twz915/DjangoUeditor3/ (直接下载zip) 2.解压,解压打开后找到DjangoUeditor将DjangoUe ...

  3. xadmin集成ueditor

    from DjangoUeditor.models import UEditorField content = UEditorField(u"内容", imagePath=&quo ...

  4. UEditor文本编辑器

    Ueditor是由百度web前端研发部开发所见即所得的编辑器,具有轻量,可定制,注重用户体验等特点.Ueditor基于BSD开源协议,除了具有代码精简.加载迅速的轻量级特质 外,还采用了分层理念,使开 ...

  5. mxonline 总结

    课程相关 课程列表 课程的剪接 课程详情 课程章节 课程关联的授课机构,课程关联的授课教师 热门课程 相关课程推荐 课程留言 需要登录 若未登录,返回到登录页面 留言失败反馈信息 留言成功,异步刷新页 ...

  6. MVC5网站开发之一 总体概述

    由于前几次都没能写完,这次年底总算有自由时间了,又想继续捣鼓一下.于是下载了VS 2015专业版(不知为什么我特别钟爱专业版,而不喜欢企业版).由于以前的教训,我这次决定写一个极简的Deom,简到什么 ...

  7. Django+Xadmin打造在线教育系统(九)

    xadmin的进阶开发 因版本问题.有些配置可能无效 自定义icon xadmin的图标采用的是第三方css样式font awesome,我们可以进官网下载最新的样式替代原本的,下载地址:http:/ ...

  8. Python爱好者社区历史文章列表(每周append更新一次)

    2月22日更新:   0.Python从零开始系列连载: Python从零开始系列连载(1)——安装环境 Python从零开始系列连载(2)——jupyter的常用操作 Python从零开始系列连载( ...

  9. 3D打印开源软件Cura分析(1) 【转】

    http://www.sohu.com/a/236241465_100000368 Cura是Ultimaker公司开发的3D打印开源软件,在所有的3D打印开源软件中应属上乘之作,很有研究的价值.国内 ...

随机推荐

  1. oracle 11g 安装步骤

    指定安装路径 输入数据库名(cwbpm),(按照自己要求输入,可以直接用默认库名) 输入密码(自定义):123456 (自定义密码) 下一步 选择“是” 点击完成,开始安装数据库 安装完成后会弹出页面 ...

  2. JS 画框操作

    Js中,我们有时候需要对图片进行操作,包括画框,其实对于UI前端来说挺简单的,没有网上说的那样复杂,这里说明一下 <div style="width:80%;height:300px; ...

  3. 执行python解释器的两种方式

    执行python解释器的两种方式 1.交互式 python是高级语言,是解释型语言,逐行翻译,写一句翻译一句 print ('hello world') 2.命令行式 python和python解释器 ...

  4. android上instant app介绍 类似于微信小程序

    android上instant app介绍 类似于微信小程序instant app 是谷歌推出的类似于微信小程序(或者说小程序类似于instant app)的一项技术,用户无须安装应用,用完就走,同时 ...

  5. nginx + keepalived 主从模式

    转自:https://www.cnblogs.com/kevingrace/p/6138185.html 负载均衡技术对于一个网站尤其是大型网站的web服务器集群来说是至关重要的!做好负载均衡架构,可 ...

  6. python接口自动化-接口重定向和编码格式

    1.如果测试的接口重定向,那么只需添加allow_redirects=False禁止重定向就可: 2.如果请求的结果,中文出现没有解码 \xe9\x83\xad\xe7\xbf\xa0\xe6\x99 ...

  7. jmeter java requst请求

    https://wangym.iteye.com/blog/731729 http://www.cnblogs.com/yangxia-test/p/4019541.html https://blog ...

  8. MySQL复制表-INSERT INTO SELECT

    基础table为: mysql> select * from staff; +----+----------+-------+ | id | name | slary | +----+----- ...

  9. 劳德巴赫下载kernel和文件系统时问题

    用劳德巴赫下载 kernel  dtb rootfs BOOT.bin 报错(记了个大概) Bad CRC Ramdisk image is corrupt or invalid 记得之前有人和我说r ...

  10. bzoj4710 [Jsoi2011]分特产(容斥)

    4710: [Jsoi2011]分特产 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 814  Solved: 527[Submit][Status] ...