1

问题一:

我正在使用 Django-CKEditor,当我尝试在其中上传任何文件或图像时,它会显示 警报错误:“服务器响应不正确”,

当我检查终端时,它显示“GET /admin/login/?next=/ckeditor/upload/HTTP/1.1”

我不知道该怎么做才能完成这项工作!请在这里帮我...

问题 2:

当我在编辑器中复制粘贴 100 行文本时,它会增加其高度,而不是在其中提供任何滚动条,这是我正在使用的配置代码:

    CKEDITOR_UPLOAD_PATH = '上传/'
    CKEDITOR_IMAGE_BACKEND = "枕头"

    CKEDITOR_CONFIGS = {
        '默认': {
            “身高”:“200”,
            “宽度”:1250,
            '工具栏_基本':[
                ['来源','-','粗体','斜体']
            ],
            'toolbar_YourCustomToolbarConfig':[
                {'name': 'document', 'items': ['Source']},
                {'name': 'clipboard', 'items': ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']},
                '/',
                {'name': '基本风格',
                 '项目':['粗体','斜体','下划线','罢工','下标','上标','-','RemoveFormat']},
                {'name': '段落',
                 'items': ['NumberedList', 'BulletedList', '-', 'Blockquote', '-',
                           'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl']},
                {'name': 'links', 'items': ['Link', 'Unlink', 'Anchor']},
                {'名称':'插入',
                 'items': ['Image', 'Table', 'SpecialChar']},
                '/',
                {'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize']},
                {'name': 'colors', 'items': ['TextColor', 'BGColor']},
                {'name': '工具', 'items': ['最大化']},
            ],
            'toolbar': 'YourCustomToolbarConfig', # 把选择的工具栏配置放在这里
            # 'toolbarGroups': [{ 'name': 'document', 'groups': ['mode', 'document', 'doctools' ] }],
            # '身高': 291,
            # '宽度': '100%',
            # 'filebrowserWindowHeight': 725,
            # 'filebrowserWindowWidth': 940,
            # 'toolbarCanCollapse':是的,
            # 'mathJaxLib': '//cdn.mathjax.org/mathjax/2.2-latest/MathJax.js?config=TeX-AMS_HTML',
            'tabSpaces': 4,
            '额外插件': ','.join([
                'uploadimage', # 上传图片功能
                # 你的额外插件在这里
                'div',
                '自动链接',
                '自动嵌入',
                '嵌入语义',
                '自动生长',
                # '开发工具',
                '小部件',
                'lineutils',
                '剪贴板',
                '对话',
                '对话',
                '元素路径'
            ]),
        }
    }

网址.py

    路径('ckeditor/',包括('ckeditor_uploader.urls')),

模型.py

    从 django.db 导入模型
    从 ckeditor_uploader.fields 导入 RichTextUploadingField

    类表名(模型。模型):
        update_message = RichTextUploadingField(空白=真,空=真)

        元类:
            db_table = "表名"

问题 3:

如何使编辑器的宽度根据屏幕自动调整。

4

1 回答 1

2

问题1:尝试替换

path('ckeditor/', include('ckeditor_uploader.urls')),

在您的 urls.py 中使用以下内容

    url(r'^ckeditor/upload/', login_required(ckeditor_views.upload), name='ckeditor_upload'),
    url(r'^ckeditor/browse/', never_cache(login_required(ckeditor_views.browse)), name='ckeditor_browse'),

还在您的 urls.py 中添加以下内容

from django.contrib.auth.decorators import login_required
from django.views.decorators.cache import never_cache
from ckeditor_uploader import views as ckeditor_views

问题 2: 编辑:您有一个额外的插件“自动增长”和错误的高度设置。

第 1 步:删除“自动增长”;

第2步:更换

'height': '200',

'height':'200px','height':200,

问题3: 替换

'width': 1250,

'width': '100%',

并在您的 html 和 css 中,使div包含 ckeditor 表单的内容具有响应性。 注意' '在您的代码中特别注意。我看到您注释掉了宽度和高度设置正确的行。

于 2019-11-17T21:55:19.817 回答