django - 无法在 django-ckeditor 中配置 youtube 插件

标签 django ckeditor

我在我的设置和模型中执行了以下操作:

settings.py

CKEDITOR_CONFIGS = {
    'special': {
        'toolbar': 'Special',
        'toolbar_Special': [
            ['Styles', 'Format', 'Bold', 'Italic', 'Underline', 'Strike', 'SpellChecker', 'Undo'],
            ['Link', 'Unlink', 'Anchor'],
            ['Image', 'Flash', 'Table', 'HorizontalRule'],
            ['TextColor', 'BGColor'],
            ['Smiley', 'SpecialChar'], ['Source'],
        ],
        'extraPlugins': 'youtube',
    }
}

models.py

class Post(models.Model):
    user    = models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE,null=True,blank=True)
    post    = RichTextUploadingField(blank=True, null=True,
                                      config_name='special',
                                      external_plugin_resources=[(
                                          'youtube',
                                          '/static/ckeditor/ckeditor/plugins/youtube_2.1.13/youtube/',
                                          'plugin.js',
                                          )],
                                      )
    date    = models.DateTimeField(auto_now_add=True)

我想在我的 ckeditor 中添加 youtube 插件。我已经从https://ckeditor.com/cke4/addon/youtube下载了.

谁能找出我的代码中的问题吗?

谢谢

最佳答案

你添加了吗

config.extraPlugins = 'youtube';

config.js文件中?

您是否在 settings.py 中配置了静态文件?

STATIC_URL = '/static/'
STATIC_ROOT = '/static/'

另请观看此视频,它可能会对您有所帮助。 https://www.youtube.com/watch?v=L6y6cn1XUfw

还有

CKEDITOR_CONFIGS = {
'default': {
    'toolbar': 'CMS',
    'toolbar_CMS': [
        {
            'name': 'basicstyles',
            'groups': ['basicstyles', 'cleanup'],
            'items': ['Bold', 'Italic', 'Underline', '-', 'RemoveFormat']
        },
        {
            'name': 'paragraph',
            'groups': ['list', 'indent', 'blocks'],
            'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote']
        },
        {
            'name': 'links',
            'items': ['Link', 'Unlink']
        },
        {
            'name': 'insert',
            'items': ['Image', 'HorizontalRule', 'Table', 'Iframe', ]
        },
        {
            'name': 'colors',
            'items': ['TextColor', 'BGColor']
        },
        {
            'name': 'youtube',
            'items': ['Youtube',]
        }
    ],
    'height': 400,
    'width': '100%',
    'allowedContent': True,
    'uiColor': '#f0f0f0',
    'extraPlugins': 'link,iframe,colorbutton,autogrow,youtube',
    'autoGrow_maxHeight': 800,
    'autoGrow_minHeight': 400,
    'removePlugins': 'resize',
    'removeButtons': None,
},
}

请确保您在项目中使用大写Y,这样会有所不同。

并检查How can I install plugin into CkEditor, Django

关于django - 无法在 django-ckeditor 中配置 youtube 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55139598/

相关文章:

django - 如何使用 django allauth 创建合适的用户?

javascript - 如何修复 Bootstrap 3 Modal + CKEditor 4.4 空对话框

ckeditor - CKEditor 中的 block /内联 'meta markup'

python - Django ORM - update() 行乘以 Decimal()

django - 用Count注释无法正常工作

ruby-on-rails - 如何允许 Rails 文本区域中的段落类似于 ckeditor 等 html 文本编辑器?

javascript - CKEditor 从 Rails 中的跨度类中剥离样式元素

javascript - CKEDITOR,AutoFocus onLoad 文本编辑器

html - Django - 使用没有静态文件的 css 显示 html

Django ModelChoiceField 使用来自一个模型属性的不同值