第一步,下载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. html5 css练习 下拉菜单制作

    *{    margin: 0;    padding: 0;}li{    list-style-type: none;}a{    text-decoration: none;}.ul1{marg ...

  2. OSM自建服务

    1.  安装PostgreSQL. 2.  安装PostGis(安装目录为PostgreSQL目录). 3.  安装osm2pgsql. osm2pgsql下载地址:http://customdebu ...

  3. springboot打成war包找不到文件

    项目在eclipse运行是可以的,但是打成war包到线上报错: FileNotFoundException: class path resource [static/apiclient_cert.p1 ...

  4. vue 异步刷新页面,

    入口文件vue.app中 <div id="app"> <router-view v-if="isRouterAlive" /> < ...

  5. java0429 wen 数据库

  6. JZ2440学习笔记之链接文件lds

    如果在Linux环境下用arm-linux-gcc来编译arm程序,需要编写链接文件lds: 1. 运行地址=链接地址,表示代码在SDRAM中执行的地址,如果程序中有对某部分代码执行过搬运,需要在ld ...

  7. android 模拟器 访问 localhost IIs Express 400错误

    如果用安卓模拟器调试本机的网站,比如 localhost:63586,是访问不到的,返回结果是 400 错误.原因是模拟器上的localhost指向的默认是模拟器自己. 解决方法是:(1) 把安卓模拟 ...

  8. 自制操作系统Antz(7)——实现内核 (上)

    Antz系统更新地址: https://www.cnblogs.com/LexMoon/category/1262287.html Linux内核源码分析地址:https://www.cnblogs. ...

  9. Getting Started with Word2Vec

    Getting Started with Word2Vec 1. Source by Google Project with Code: https://code.google.com/archive ...

  10. 关于SQL优化的一点建议

    前段时间一直在做关于性能优化相关的工作,结合自己的实际工作经验,只针对SQL层面提一些优化的规范和建议. 针对SQL编写 1.单条SQL长度不宜超过100行: 2.SQL子查询不宜嵌套3层: 子查询嵌 ...