django项目集成富文本编辑器

第一步,将ueditor编辑器相关配置文件(ueditor.all.min.js和ueditor.config.js加载至静态文件下面,并且创建一个ueditor的视图)

 第二步,在主配置文件settings.py中加入如下

UEDITOR_UPLOAD_TO_SERVER = True
UEDITOR_UPLOAD_PATH = MEDIA_ROOT
UEDITOR_CONFIG_PATH = os.path.join(BASE_DIR,'front', 'dist','ueditor','config.json')

第三步,在html中替换输入文本框,如果你用的是adminLTE框架外层div必须加form-group样式

 第四步,编写js文件,初始化ueditor

//初始化ueditor
News.prototype.initUeditor = function () {
    window.ue = UE.getEditor('editor',{
        'initialFrameHeight': 400,
        'serverUrl': '/ueditor/upload/'
    });

};

第五步,刷新浏览器会看到如下效果

猜你喜欢

转载自www.cnblogs.com/fengzi7314/p/12691985.html