首页 > 解决方案 > Django | CKEditor - Image Upload option not showing in App

问题描述

In admin all CKEditor option is showing and working properly. I can upload image in main admin dashboard. But in App in Image "Uoload" option is not showing. Please see those images than you have a clear view,

Image 1 enter image description here

Image 2 enter image description here

Others option is working properly without image Upload.

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>

标签: djangockeditordjango-ckeditor

解决方案


我刚刚在 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"
    )

代码官方repo ckeditor


推荐阅读