django的富文本编辑器

问题描述 投票:0回答:2

我正在尝试为我的项目添加一个富文本编辑器。对Django中的开源Richtexteditor有什么建议吗?应包含图片上传,视频上传和文件上传的选项。

python django upload open-source rich-text-editor
2个回答
0
投票

我尝试了很多编辑器,但没有找到完美的免费版本。 Froala Editor很好,但是它不是免费的。您也可以尝试CKeditor。


0
投票

我使用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的更多信息。

© www.soinside.com 2019 - 2024. All rights reserved.