django - 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,
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>
解决方案
我刚刚在 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"
)
推荐阅读
- firebase - Http 或 Https 以连接到 Firebase?
- php - 随机排序名称列表以根据 2 个限制创建第二个列表(地图)
- pyspark - 在pyspark中旋转一行的值
- javascript - Ajax 请求失败:JSON 意外结束
- c# - 在 WPF 中将可点击的超链接实现到数据网格中
- c++ - 如何调试使用循环和排序的程序?
- java - 单线程执行期间事务失败
- ubuntu - 负载测试:不稳定的错误“连接被拒绝”
- python-3.x - 计算给定时间范围内的最大 CPU Python
- arrays - 如何在 Microsoft Access VBA 中将字符串转换为实际的表单标签标题?