【项目django-后端07】ueditor编辑器

网站:https://ueditor.baidu.com/website/onlinedemo.html

  • 查看文档
  • 集成ueditor编辑器,
  • 前端代码:ueditor放入(front>>dist>>ueditor)
  • 后端代码:ueditor放入(app>>ueditor)
  • settings >
    'apps.ueditor',
UEDITOR_UPLOAD_TO_SERVER = True
UEDITOR_UPLOAD_PATH = MEDIA_ROOTUEDITOR_CONFIG_PATH = os.path.join(BASE_DIR,'front','dist','ueditor','config.json')
  • urls >
    path('ueditor/',include('apps.ueditor.urls'))
  • html >
    <script src="{% static 'ueditor/ueditor.config.js' %}"></script>
    <script src="{% static 'ueditor/ueditor.all.min.js' %}"></script>
    <script id="editor" type="text/plain">
  • js >
    传入ID
    News.prototype.initUEditor = function () {
        window.ue = UE.getEditor('editor',{
            'initialFrameHeight': 400,
            'serverUrl': '/ueditor/upload/'
        });
    };

    效果:

注意:上传图片视频不可用

  • 上传到七牛settings>
  • # Qiniu配置
    QINIU_ACCESS_KEY = 'M4xxxxxxxxxxxxxL'
    QINIU_SECRET_KEY = '7BKV7xxxxxx4'
    QINIU_BUCKET_NAME = 'xhdake'
    QINIU_DOMAIN = 'http://7xqenu.com1.z0.glb.clouddn.com/'
    
    # 七牛和自己的服务器,最少要配置一个
    # UEditor配置
    UEDITOR_UPLOAD_TO_QINIU = True
    UEDITOR_QINIU_ACCESS_KEY = QINIU_ACCESS_KEY
    UEDITOR_QINIU_SECRET_KEY = QINIU_SECRET_KEY
    UEDITOR_QINIU_BUCKET_NAME = QINIU_BUCKET_NAME
    UEDITOR_QINIU_DOMAIN = QINIU_DOMAIN

     

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章