用 django 写了一个网站,然后后台的编辑器太简陋了,于是就装了富文本编辑器 ckeditor 并且设置了上传图片到服务器.在本地测试没有问题,部署到服务器 ubuntu ,上传图片就不行了,本应该显示图片的框框里结果显示 server error 500 错误。 由于我在 stackoverflow 上提问了,所以就不重写一次了。 会的朋友帮看看,感谢! http://stackoverflow.com/questions/41219168/uploading-images-use-django-ckeditor-getting-server-error500
I have been struggling for the problem for two days. Unfortunately, i still have no idea to solve it due to my poor knowledge. So i have to come here asking for help. Very appreciate !
enter image description here
I want to write a website as my blog and use Django to implement it. To develop this website, i have to use rich text editor, so i use CKeditor on admin panel. Here is the link of Ckeditor source code on github. https://github.com/django-ckeditor/django-ckeditor
To upload images using ckeditor widget , i edited this file../static/ckeditor/ckeditor/plugins/image/di alogs/image.js so it can display the images upload button.
id:"Upload",hidden:!0 I also added upload url in config.js. After that, i set routing in the urls.py and added a view function in views.py. Everything was ok on my computer. however, after i deployed it to website server i got server error(500) during uploading a image by ckeditor . Ckeditor widget can not return the urls but i can find the images on server which i uploaded by ckeditor.
1
wenymedia 2016-12-19 17:55:25 +08:00 via Android
检查写入权限
|
2
glasslion 2016-12-19 18:02:36 +08:00
配下 log, 看看错误堆栈吧. 光给个 500 很难定位
|
3
tairan2006 2016-12-19 18:13:20 +08:00
可能是权限问题吧,你把 settings.py 里面的`debug=True`打开,会看到更多有用信息。。
|
4
gooesberry OP @tairan2006 @glasslion @wenymedia 在服务器能找到文件,说明可以上传,只是返回 url 的时候出错, debug=True 开了,依然也只显示 500.怎么配置 log 呢?
|
5
zzlettle 2016-12-19 20:59:42 +08:00
|
6
jarlyyn 2016-12-19 21:02:48 +08:00
1.ckeditor 是一个前端插件
2.文件上传部分我用的时候是自己写的, Js 对接上去的。 |
7
syv2 2016-12-19 22:16:10 +08:00
如果出错的话,即便异常被捕获了,之后的那个 res 里引用的 file_name 是没定义的
|
8
freestyle 2016-12-19 22:19:38 +08:00
权限问题.
ls -l 看一下图片上传的目的目录的所有者和权限 再 ps -aef 对比你 django wsgi server 的用户组 |