django-ckeditor设置placeholder属性

thawne

930

2021-03-06

新博客换了很多编辑器,最终选择了ckeditor,原因是开源免费,一直维护,且用户量多,本站用的是django-ckeditor,内置的CKEditor 4.14.1。

设置过程中,在forms进行如下设置没法显示placeholder属性

 

class Form(forms.ModelForm):

    class Meta:
        ...
        widgets = {
            'body': forms.Textarea(attrs={'placeholder': 'blabla'})
        }

但没什么卵用,并且在settings.py里直接设置也不行。

ckeditor自带一个placeholder占位符插件,所以搜索出来都是这个。

浏览官方文档发现,用Configuration Helper插件就可以了,下载后解压放到Lib\site-packages\ckeditor\static\ckeditor\ckeditor\plugins

然后在settings.py里直接添加ckeditor设置就行了

附上评论区的ckeditor配置

CKEDITOR_CONFIGS = {
    'default': {
        'height': 100,
        'width': 'auto',
        'language': 'zh-cn',
        'CKEDITOR_RESTRICT_BY_USER': True,
        'toolbar': 'Custom',
        'placeholder': '不有佳咏,何伸雅怀?',
        'toolbar_Custom': [
            ['Bold', 'Italic', 'Underline', 'TextColor', 'BGColor'],
            ['RemoveFormat', 'Format', 'Font', 'FontSize', 'BulletedList'],
            ['Blockquote', 'CodeSnippet''NumberedList', ],
            ['Image', 'Link', 'Unlink'],
            ['Maximize'],
            ['Source', '-', 'DocProps', 'Preview', 'PasteFromWord', 'About']
        ],
        'extraPlugins': ','.join(['codesnippet', 'uploadimage', 'widget', 'lineutils', 'confighelper']),
    },
}

发表你的看法

1 评论

The vws.tjou.qqsign.cn.ipi.ge failed [URL=http://elearning101.org/item/stromectol-best-price-usa/]stromectol without a prescription[/URL] [URL=http://thegrizzlygrowler.com/item/buying-prednisone-online/]prednisone 5 mg generic[/URL] [URL=http://stephacking.com/drugs/stromectol-capsules/]stromectol buy in canada[/URL] [URL=http://thegrizzlygrowler.com/item/prednisone-without-a-doctor/]prednisone[/URL] [URL=http://mrcpromotions.com/pill/generic-for-stromectol/]non prescription stromectol[/URL] [URL=http://aawaaart.com/prednisone-lowest-price/]prednisone price at walmart[/URL] [URL=http://brisbaneandbeyond.com/product/mail-order-prednisone/]prednisone[/URL] [URL=http://coastal-ims.com/non-prescription-stromectol/]stromectol best price[/URL] stromectol.com lowest price [URL=http://anguillacayseniorliving.com/product/prednisone-best-price/]prednisone best price[/URL] hopeless blue supplementation stromectol prednisone buy buying prednisone online buying stromectol prednisone without a doctor prednisone without a doctor buy stromectol prednisone price at walmart buy cheap prednisone stromectol best price compare prednisone pricing staining losses: shingles http://elearning101.org/item/stromectol-best-price-usa/ stromectol http://thegrizzlygrowler.com/item/buying-prednisone-online/ montreal prednisone http://stephacking.com/drugs/stromectol-capsules/ buying stromectol http://thegrizzlygrowler.com/item/prednisone-without-a-doctor/ generic prednisone canada http://mrcpromotions.com/pill/generic-for-stromectol/ non prescription stromectol http://aawaaart.com/prednisone-lowest-price/ prednisone prednisone best price http://brisbaneandbeyond.com/product/mail-order-prednisone/ lowest prednisone prices http://coastal-ims.com/non-prescription-stromectol/ stromectol http://anguillacayseniorliving.com/product/prednisone-best-price/ prednisone online pharmacy buds valproate then, models.

2021年10月7日 23:31

回复