Home > Enterprise >  How to resize django ckeditor according to the window size?
How to resize django ckeditor according to the window size?

Time:10-28

I am going to add a Django CKEditor to my form but it is not resized when I resize my window size. Please help me to fix it.

models.py

from ckeditor.fields import RichTextField
Body  = RichTextField()

forms.py

    widgets = {
        'created_date': forms.DateTimeInput(attrs={
            'class':'form-control',
            'readonly':'True',
            }) ,
        'Title' : forms.TextInput(attrs={
            'class':'form-control'
            }),
        'Body': forms.Textarea(attrs={
            'class':'form-control django-ckeditor-widget ckeditor',
            'id':'form-control',
            'spellcheck':'False'}),
    }

settings.py

CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': [
            ['Undo', 'Redo',
             '-', 'Bold', 'Italic', 'Underline',
             '-', 'Link', 'Unlink', 'Anchor',
             '-', 'Format',
             
             '-', 'Maximize',
             
            ],
        ],
        
        
        
        'toolbarCanCollapse': True,
    },
}

template.html

      {{ form.media }}
  {{form.as_p}}

CodePudding user response:

Add 'width': 'auto' to your settings.py file

CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': [
            ['Undo', 'Redo',
             '-', 'Bold', 'Italic', 'Underline',
             '-', 'Link', 'Unlink', 'Anchor',
             '-', 'Format',
             
             '-', 'Maximize',
             
            ],
        ],  
        'width': 'auto',
        'toolbarCanCollapse': True,
    },
}
  • Related