Django中使用富文本编辑器:Ueditor 详解

Django中使用富文本编辑器:Ueditor 详解 1.安装Ueditor包pip install DjangoUeditor2.配置settings.py加入appINSTALLED_APPS = [ 'django.contrib.admin', ... 'DjangoUeditor', ]配置富文本编辑器的文件存放路径MEDIA_URL ='/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media')3.配置URLfrom django.conf.urls.static import static from 统计局 import settings import os urlpatterns = [ ... path('ueditor/', include('DjangoUeditor.urls')), ] if settings.DEBUG: media_root = os.path.join(settings.BASE_DIR, settings.MEDIA_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=media_root)4.设置models.py中相应字段的类型from DjangoUeditor.models import UEditorField class xxx(models.Model): content = UEditorField('内容', width=600, height=300, toolbars="full", imagePath="", filePath="", upload_settings={"imageMaxSize" : 1204000}, set