Django | CKEditor-“图像上传”选项未在应用中显示

时间:2018-12-08 15:43:29

标签: django ckeditor django-ckeditor

在admin中,所有CKEditor选项均显示并正常工作。我可以在主管理控制台中上传图片。但是在图像中的应用程序中,“ Uoload”选项未显示。请查看那些图片,以免看到清晰的画面,

图片1 enter image description here

图片2 enter image description here

其他选项在没有上传图片的情况下正常运行。

settings.py

THIRD_PARTY_APPS = [
    'widget_tweaks',
    'ckeditor',
    'ckeditor_uploader',
]

INSTALLED_APPS += THIRD_PARTY_APPS + LOCAL_APPS

# CkEditor Upload path
CKEDITOR_UPLOAD_PATH = 'uploads/'

# CkEditor Custom Configuration
CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'Custom',
        'width': 680,
        'extraPlugins': ','.join(['codesnippet']),
    },
}

template.html

<form method="post" enctype="multipart/form-data">{% csrf_token %}>
{{ form.media }}
{{ form.as_p }}
<button type="submit">Submit</button>
</form>

2 个答案:

答案 0 :(得分:0)

第1步: 转到settings.py并添加-> X_FRAME_OPTIONS ='SAMEORIGIN'

第二步 转到您的forms.py-> 这里不需要额外的小部件。 step2

答案 1 :(得分:0)

我刚刚在 django-ckeditor 6.1.0 版中遇到了同样的问题。 想了想,查看项目的github代码,显然有一个新的表单域解决了这个问题,至少现在对我来说,如果它对我来说效果很好。

from django import forms
from ckeditor.fields import RichTextFormField
from ckeditor_uploader.fields import RichTextUploadingFormField



class CkEditorForm(forms.Form):
    ckeditor_standard_example = RichTextFormField()
    ckeditor_upload_example = RichTextUploadingFormField(
        config_name="my-custom-toolbar"
    )

code oficial repo ckeditor