安装django-editor
>python -m pip install django-ckeditor
配置media路径
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
CKEDITOR_UPLOAD_PATH = 'upload/' ##那么ckeditor媒体文件会上传到media/upload目录下
配置项目包下的映射路径
同时在路由下添加:
修改模型类
from ckeditor_uploader.fields import RichTextUploadingField
content = RichTextUploadingField(null=True, blank=True)