通过运营界面上传图片失败,浏览器提示上传文件时发生HTTP错误(错误代码:500)

通过运营界面上传图片失败,浏览器提示上传文件时发生HTTP错误(错误代码:500)


ERROR exception 135 Internal Server Error: /ckeditor/upload/
Traceback (most recent call last):
  File "/home/python/.virtualenvs/django_meiduo/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/python/.virtualenvs/django_meiduo/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/python/.virtualenvs/django_meiduo/lib/python3.5/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/python/.virtualenvs/django_meiduo/lib/python3.5/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/home/python/.virtualenvs/django_meiduo/lib/python3.5/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/python/.virtualenvs/django_meiduo/lib/python3.5/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/python/.virtualenvs/django_meiduo/lib/python3.5/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/python/.virtualenvs/django_meiduo/lib/python3.5/site-packages/ckeditor_uploader/views.py", line 95, in post
    if(str(saved_path).split('.')[1].lower() != 'gif'):
IndexError: list index out of range
ERROR basehttp 124 "POST /ckeditor/upload/ HTTP/1.1" 500 97951


重点看这一句---if(str(saved_path).split('.')[1].lower() != 'gif')

通过运营界面上传图片失败,浏览器提示上传文件时发生HTTP错误(错误代码:500)_第1张图片

通过运营界面上传图片失败,浏览器提示上传文件时发生HTTP错误(错误代码:500)_第2张图片

我们将通过Django上传的图片保存到了FastDFS中,而保存在FastDFS中的文件名没有后缀名,ckeditor在处理上传后的文件名按照有后缀名来处理,所以会出现bug错误

找到虚拟环境目录中的ckeditor_uploader/views.py文件如:
~/.virtualenvs/meiduo/lib/python3.5/site-packages/ckeditor_uploader/views.py

将第95行代码修改如下:

通过运营界面上传图片失败,浏览器提示上传文件时发生HTTP错误(错误代码:500)_第3张图片

然后就成功上传

通过运营界面上传图片失败,浏览器提示上传文件时发生HTTP错误(错误代码:500)_第4张图片

你可能感兴趣的:(python项目开发,django)