安装好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})