Django学习---py3下的富文本编辑器的使用

  • 背景说明:
      Ueditor HTML编辑器是百度开源的HTML编辑器,但是在Python3下调用报错,找不到widgets模块,经查发现,DjangoUeditor是基于Python 2.7的,对Python3的支持有问题。导致widgets.py文件出错,不能import。
 
  • 安装DjangoUeditor3:
     使用博主的Ueditor文件(来源github上修改好的版本DjangoUeditor3),点击下载(内附安装教程)
 
  • 配置DjangoUeditor3

manas/settings.py

image

# 富文本编辑器配置
TINYMCE_DEFAULT_CONFIG = {
    'theme': 'advanced',
    'width': 600,
    'height': 400,
}

image

manas/urls.py

image

配置models.py文件: df_goods/models.py

from DjangoUeditor.models import UEditorField

image

原文地址:https://www.cnblogs.com/ftl1012/p/10388783.html