【问题标题】:How to resize django ckeditor according to the window size?如何根据窗口大小调整 django ckeditor 的大小?
【发布时间】:2021-12-12 20:26:35
【问题描述】:

我将在我的表单中添加一个 Django CKEditor,但是当我调整我的窗口大小时它没有调整大小。请帮我解决它。

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,
    },
}

模板.html

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

【问题讨论】:

    标签: django ckeditor django-ckeditor


    【解决方案1】:

    'width': 'auto' 添加到您的 settings.py 文件中

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-07
      • 1970-01-01
      • 2014-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-28
      • 1970-01-01
      相关资源
      最近更新 更多