【項目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

     

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