Django-CKEditor不会渲染图像 [英] Django-CKEditor won't render images
问题描述
我已经安装了Django-CKEditor并为开发目的配置它。
现在我可以编辑文本并将其作为文本字段保存到db。但是插入图片我有主要的问题...
我可以插入图像,似乎保存到本地主机(正确的文件夹),但渲染图像预览或文本编辑器我只得到破碎的图像图片。
显然我没有正确配置settings.py。来自settings.py的主要项目:
MEDIA_ROOT =''
MEDIA_URL ='/ media /'
STATIC_ROOT =''
STATIC_URL ='/ static /'
CKEDITOR_UPLOAD_PATH ='media / uploads /'
CKEDITOR_UPLOAD_PREFIX ='media / uploads /'
也尝试过类似于django-ckeditor testproject的配置有,但面对类似的破碎的渲染图像。
我使用windows环境进行开发。 Django-ckeditor版本为 4.0.2
$ b $
发现根本原因。
调试后发现django-ckeditor有问题,Windows的反斜杠。
首先我做了我自己的更正,但最后还发现,这已经报告和更正提议,但尚未合并到主分支:
< a href =https://github.com/shaunsephton/django-ckeditor/pull/41 =nofollow>在Windows中修正反斜杠问题
I've installed Django-CKEditor and configurated it for development purposes.
Now I can edit text and save it to db as text field. But with inserting images I have major problems...
I can insert image and it seems to save properly to local host (to correct folder) but when rendering image to preview or text editor I get only broken image picture. Apparently I haven't configured settings.py correctly. Main items from settings.py:
MEDIA_ROOT = ''
MEDIA_URL = '/media/'
STATIC_ROOT = ''
STATIC_URL = '/static/'
CKEDITOR_UPLOAD_PATH = 'media/uploads/'
CKEDITOR_UPLOAD_PREFIX = 'media/uploads/'
Also tried similar configuration than django-ckeditor testproject has but faced similar broken rendering images.
I'm using windows environment for development. Django-ckeditor version is 4.0.2
Any ideas what is wrong or where to start solving this?
Found the root cause.
After debugging it found out that django-ckeditor has problems with Windows back-slashes. First I made my own correction but finally also found out that this has been already reported and correction proposal also made but not yet merged to master branch:
Fixing trouble with backward slashes in Windows
这篇关于Django-CKEditor不会渲染图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!