Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Youtube按钮在django CKEditor中不显示_Django - Fatal编程技术网

Youtube按钮在django CKEditor中不显示

Youtube按钮在django CKEditor中不显示,django,Django,我一直在关注youtube教程: 唉,菜单上出现的youtube按钮可真倒霉。 我只想让YouTube插件成为“自定义”工具栏的一部分,而不是创建额外的“特殊”工具栏项目,但显然这是一个禁飞区 尝试视频中推荐的方法也不起作用;我在包含以下内容的行中遇到错误: 'config.extraPlugins': ','.join(['youtube', 'codesnippet']), 我错过了什么 在main/settings.py中: CKEDITOR_CONFIGS = { 'defa

我一直在关注youtube教程:

唉,菜单上出现的youtube按钮可真倒霉。 我只想让YouTube插件成为“自定义”工具栏的一部分,而不是创建额外的“特殊”工具栏项目,但显然这是一个禁飞区

尝试视频中推荐的方法也不起作用;我在包含以下内容的行中遇到错误:

'config.extraPlugins': ','.join(['youtube', 'codesnippet']),
我错过了什么

main/settings.py中:

CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'Custom',
        'height': 250,
        'width': '100%',
        'toolbar_Custom': [
            ['Styles', 'Format'],
            ['Bold', 'Italic', 'Underline', 'Strike', 'Undo', 'Redo'],
            ['Link', 'Image', 'Table', 'Youtube'],
            ['TextColor', 'SpecialChar', 'CodeSnippet'],
            ['Source']
        ],
        'config.extraPlugins': ','.join(['youtube', 'codesnippet']),
    },
class Post(models.Model):
    name        = models.CharField(max_length=120, null=False, blank=False)
    author      = models.ForeignKey(User, on_delete=models.CASCADE)
    category    = models.ForeignKey(Category, on_delete=models.CASCADE)
    content     = RichTextUploadingField(
                                    null=False,
                                    blank=False,
                                    # config_name='toolbar_Custom',
                                    external_plugin_resources=[(
                                        'youtube',
                                        '/static/ckeditor/ckeditor/plugins/youtube/',
                                        'plugin.js',
                                    )],
                                    )
    timestamp   = models.DateTimeField(auto_now_add=True)
    updated     = models.DateTimeField(auto_now=True)
    slug        = models.SlugField(max_length=70, blank=True, null=True, help_text='<small><font color="red">don\'t. touch. the. slug. field. unless. you. mean. it.</font> (it will auto-generate, don\'t worry.)</small>')
注意:教程说只需使用设置文件第13行中的
extraPlugins
,但这会导致CKEditor根本不显示,因此我添加了
config.
,它会再次运行。。。老实说,这是一件很麻烦的工作

在blog/models.py中:

CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'Custom',
        'height': 250,
        'width': '100%',
        'toolbar_Custom': [
            ['Styles', 'Format'],
            ['Bold', 'Italic', 'Underline', 'Strike', 'Undo', 'Redo'],
            ['Link', 'Image', 'Table', 'Youtube'],
            ['TextColor', 'SpecialChar', 'CodeSnippet'],
            ['Source']
        ],
        'config.extraPlugins': ','.join(['youtube', 'codesnippet']),
    },
class Post(models.Model):
    name        = models.CharField(max_length=120, null=False, blank=False)
    author      = models.ForeignKey(User, on_delete=models.CASCADE)
    category    = models.ForeignKey(Category, on_delete=models.CASCADE)
    content     = RichTextUploadingField(
                                    null=False,
                                    blank=False,
                                    # config_name='toolbar_Custom',
                                    external_plugin_resources=[(
                                        'youtube',
                                        '/static/ckeditor/ckeditor/plugins/youtube/',
                                        'plugin.js',
                                    )],
                                    )
    timestamp   = models.DateTimeField(auto_now_add=True)
    updated     = models.DateTimeField(auto_now=True)
    slug        = models.SlugField(max_length=70, blank=True, null=True, help_text='<small><font color="red">don\'t. touch. the. slug. field. unless. you. mean. it.</font> (it will auto-generate, don\'t worry.)</small>')
class Post(models.Model):
name=models.CharField(最大长度=120,null=False,blank=False)
author=models.ForeignKey(用户,on_delete=models.CASCADE)
类别=模型.ForeignKey(类别,on_delete=模型.CASCADE)
content=RichTextUploadingField(
null=False,
空白=假,
#config_name='toolbar_Custom',
外部插件资源=[(
“youtube”,
“/static/ckeditor/ckeditor/plugins/youtube/”,
'plugin.js',
)],
)
timestamp=models.DateTimeField(auto\u now\u add=True)
updated=models.DateTimeField(auto\u now=True)
slug=models.SlugField(max_length=70,blank=True,null=True,help_text='don't.touch.the.slug.field.except.you.mean.it.(它将自动生成,不用担心。))

在settings.py中使用以下代码:

    'extraPlugins': ','.join(
        [
           'youtube',
        ]
    ),
并在blog/models.py中检查路径是否正确:

“/static/ckeditor/ckeditor/plugins/youtube/”

也许你应该把它改成

“/static/ckeditor/ckeditor/plugins/youtube/youtube/