xadmin 集成ckeditor并解决上传视频问题
安装
pip install django-ckeditor
settings.py
INSTALLED_APPS = [
...
'ckeditor',
'ckeditor_uploader',
]
CKEDITOR_UPLOAD_PATH = 'editor'
CKEDITOR_IMAGE_BACKEND = 'pillow'
CKEDITOR_FILENAME_GENERATOR = 'utils.upload_path.create_filename'
CKEDITOR_CONFIGS = {
'default': {
'toolbar': 'full',
'height': 300,
'width': 900
}
}
urls.py
path('editor/', include('ckeditor_uploader.urls')),
models.py
from ckeditor_uploader.fields import RichTextUploadingField
class Nodes(models.Model):
content = RichTextUploadingField(null=True, blank=True, verbose_name='详情')
同步数据库之后,就可以了。
解决问题:没有上传视频的功能
点击下载 html5video
-
解压后的文件夹放到python \site-packages\ckeditor\static\ckeditor\ckeditor\plugins 目录下。
-
修改\site-packages\ckeditor\static\ckeditor\config.js
CKEDITOR.editorConfig = function( config ) { config.language = 'zh-cn', config.extraPlugins = 'html5video'; };