有没有做 python django 开发的?我在后台装了个 ckeditor 结果 sever error 500 了,求大神帮忙!

2016-12-19 17:43:43 +08:00
 gooesberry

用 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.

4229 次点击
所在节点    Django
8 条回复
wenymedia
2016-12-19 17:55:25 +08:00
检查写入权限
glasslion
2016-12-19 18:02:36 +08:00
配下 log, 看看错误堆栈吧. 光给个 500 很难定位
tairan2006
2016-12-19 18:13:20 +08:00
可能是权限问题吧,你把 settings.py 里面的`debug=True`打开,会看到更多有用信息。。
gooesberry
2016-12-19 18:23:22 +08:00
@tairan2006 @glasslion @wenymedia 在服务器能找到文件,说明可以上传,只是返回 url 的时候出错, debug=True 开了,依然也只显示 500.怎么配置 log 呢?
zzlettle
2016-12-19 20:59:42 +08:00
正好我前段时间专门做了一期 django 跟编辑器的整合的视频教程
地址在这里
http://www.fanhuaxiu.com/article/840/
jarlyyn
2016-12-19 21:02:48 +08:00
1.ckeditor 是一个前端插件
2.文件上传部分我用的时候是自己写的, Js 对接上去的。
syv2
2016-12-19 22:16:10 +08:00
如果出错的话,即便异常被捕获了,之后的那个 res 里引用的 file_name 是没定义的
freestyle
2016-12-19 22:19:38 +08:00
权限问题.
ls -l 看一下图片上传的目的目录的所有者和权限
再 ps -aef 对比你 django wsgi server 的用户组

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/328694

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX