【问题标题】:How to install CKEditor plugin in Django如何在 Django 中安装 CKEditor 插件
【发布时间】:2016-07-27 04:04:42
【问题描述】:

我正在尝试为 django-CKEditor 的图像上传器安装插件。但是,这些按钮不会出现在 CKeditor 小部件中。

我安装CKEditor插件的步骤如下:

  1. 下载并解压 CKEditor 插件的 Image Uploader 和 Browser。
  2. 将解压后的文件复制到CKeditor的静态文件夹,即/project/static/ckeditor/ckeditor/plugins/imageuploader。还尝试使用 manage.py collectstatic
  3. 如下配置settings.py文件。

    CKEDITOR_CONFIGS = {
        'default': {
            'toolbar': [
                [      'Undo', 'Redo',
                  '-', 'Bold', 'Italic', 'Underline',
                  '-', 'Link', 'Unlink', 'Anchor',
                  '-', 'Format',
                  '-', 'SpellChecker', 'Scayt',
                  '-', 'Maximize',
                ],
            ],
            'width': 840,
            'height': 300,
            'toolbarCanCollapse': False,
        },
    
        'simple_toolbar': {
            'toolbar': [['imageuploader',],],
            'width': 840,
            'height': 300,
            'removePlugins': 'stylesheetparser',
            'extraPlugins': 'imageuploader',
        },
    
    }
    
  4. 如下配置小部件。

    class Form(forms.ModelForm):
        description=forms.CharField(widget=CKEditorWidget(config_name='simple_toolbar'
    ))
    

【问题讨论】:

    标签: python django ckeditor django-ckeditor


    【解决方案1】:

    试试这个:

    在你的模型中:

    class YouModel(models.Model)
        text = HTMLField(configuration='CKEDITOR_SETTINGS_MODEL1', blank=True)
    

    在 settings.py 文件中:

    CKEDITOR_SETTINGS_MODEL1 = {
        'language': '{{ language }}',
        'toolbar_HTMLField': [
        {'name': 'basicstyles', 'items': ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']},
            {'name': 'colors', 'items': ['TextColor', 'BGColor']},
            {'name': 'paragraph', 'items': ['NumberedList', 'BulletedList', 'Outdent', 'Indent', 'Blockquote', 'JustifyLeft', 'JustifyCenter', 'JustifyRight',
                        'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 'Language']},
            {'name': 'clipboard', 'items': ['Paste', 'Undo', 'Redo']},
            {'name': 'tools', 'items': ['Maximize']},
            {'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize', 'Scayt']},
            {'name': 'document', 'items': ['Preview', 'Print']},
            {'name': 'editing', 'items': ['Find', 'Replace', 'SelectAll']},
            {'name': 'links', 'items': ['Link', 'Unlink', 'Table', 'SpecialChar', 'Smiley']},
        ],
        'height': '777px',
        'width': '759px',
        'scayat_slang': ['en_US, en_GB, pt_BR, da_DK, nl_NL, en_CA, fi_FI, fr_FR, fr_CA, de_DE, el_GR, it_IT, nb_NO, pt_PT, es_ES, uk_UK'],
        'removePlugins': 'elementspath',
        'extraPlugins': ','.join(['div', 'clipboard', 'dialog', 'scayt',]), 
    }
    

    你可以改变这个大小,按钮,其他

    【讨论】:

    • 如果你有图片上传插件,只需添加到工具栏
    猜你喜欢
    • 2016-04-05
    • 2018-08-03
    • 1970-01-01
    • 1970-01-01
    • 2015-01-19
    • 2020-02-17
    • 2020-04-30
    • 1970-01-01
    • 2021-07-27
    相关资源
    最近更新 更多