简体   繁体   English

如何设置 django-ckeditor 的占位符属性

[英]how to set the placeholder property of django-ckeditor

while using django-ckeditor for my website, i want to set the 'placeholder' property for the editor在为我的网站使用 django-ckeditor 时,我想为编辑器设置“占位符”属性

I've tried to work directly in settings.py like this:我尝试像这样直接在 settings.py 中工作:

CKEDITOR_CONFIGS = {
    'default': {
        ...
        'extraPlugins': ','.join(['placeholder']),
        'placeholder': 'blabla'
    },
}

and i tried this in my_app/forms.py:我在 my_app/forms.py 中尝试了这个:

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

but it didn't work?但它没有用? what should i do?我应该怎么办?

Try this..尝试这个..

setings.py:设置.py:

CKEDITOR_CONFIGS = {
    'special': 
        {'toolbar': 'Special', 'height': 1000,'width':1000,
         'config.toolbarGroups': 
             [
                 ['Bold', 'Image'],
             ],                          ⬇⬇⬇⬇⬇⬇⬇⬇
             'extraPlugins': ','.join(['placeholder',]),
         }
}

models.py:模型.py:

class Post(models.Model):
    body = RichTextUploadingField(blank=True,config_name='special')

Image :图片 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM