下载ckeditor
pip install django-ckeditor
#如果可以下载pillow
pip install Pillow
加入到应用中
setting.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'ckeditor',
'ckeditor_uploader',
'mysite',
]
添加图片上传相对路径
setting.py
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
配置ckeditor
CKEDITOR_UPLOAD_PATH = 'upload/'
``
将 模型中的文本输入替换
models.py
from ckeditor_uploader.fields import RichTextUploadingField
content = RichTextUploadingField()
在映射中加入ckeditor路径
urls.py
path('ckeditor', include('ckeditor_uploader.urls')),