python安装djangp-ueditor后需要注意的事项

作者: dreamfly 分类: python 发布时间: 2019-05-12 13:04

安装好django-ueditor这个扩展包之后,我们还需要修改一些配置文件,我们才能正常使用ueditor,下面简单介绍下需要修改的内容。

  1. 修改settings.py配置文件

    QINIU_BUCKET = ''

      MEIDA_ROOT = os.path.join(BASE_DIR,"media")
      MEDIA_URL = '/media/'

2.  安装缺失的包

    pip install shortuuid

   pip install qiniu

3.模型中引入ueditor

  from ueditor import UEditorField

  

  content = UEditorField("内容",default="")

4. 修改ueditor源码包中的widgets.py文件

将grp.jQuery 替换成 django.jQuery

5.修改路由配置

from web.settings import MEDIA_ROOT

from django.views.static import serve

re_path(r'^ueditor/',include('ueditor.urls')),

re_path(r'^media/(?P<path>.*)$', serve, {'document_root': MEDIA_ROOT})

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!