我正在尝试为我的项目添加一个富文本编辑器。 对Django中的开源Richtexteditor有什么建议吗? 应包含图片上传,视频上传和文件上传的选项。
答案 0 :(得分:2)
我使用django-ckeditor。
要在您的项目中使用,请安装pip,然后在settings.py的istalled_apps中添加“ ckeditor”和“ ckeditor_uploader”。
为了更好地工作,请将其添加到settings.py:
CKEDITOR_CONFIGS = {
'default': {
'toolbar': 'Custom',
'width': '100%',
'tabSpaces': 4,
'toolbar_Custom': [
['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'],
['TextColor', 'BGColor'],
['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', 'Blockquote', 'BidiLtr', 'BidiRtl'],
['Link', 'Unlink', 'Anchor'],
['Source'],
['Styles', 'Format', 'Font', 'FontSize'],
['Youtube', 'Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe'],
]
}
}
CKEDITOR_BASEPATH = "{}/ckeditor/ckeditor".format(STATIC_URL)
然后,在您的主urls.py中的同一级别的settings.py中,将其添加:
path('ckeditor/', include('ckeditor_uploader.urls')),
详细了解ckeditor here。