Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
513 views
in Technique[技术] by (71.8m points)

How to resize django ckeditor inside the form model

I need to use django-ckeditor in various part of my project, so for each part need to resize it.

But I know that I can resize it by adding this definitions in settings as below:

INSTALLED_APPS = [
    'ckeditor',
]

CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'Basic',
         'height': 70,
         'width': 430,
    },
}

however, as I mentioned above, I am using several editor in different parts, so need to resize them differently.

How to reside in different form.fields?

class proForm(forms.ModelForm):

    description = forms.CharField(widget=CKEditorWidget())
    class Meta:
        fields = ('__all__')

This raises error:

description = forms.CharField(widget=CKEditorWidget({
        'toolbar': 'Basic',
         'height': 70,
         'width': 430,
    }))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Have a look at https://github.com/django-ckeditor/django-ckeditor#optional-customizing-ckeditor-editor

It seems you can define multiple set of editors and give config_name when instantiating the field.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...