Django(Python)AttributeError:’NoneType’对象没有属性’split’

Django(Python)AttributeError:’NoneType’对象没有属性’split’,第1张

概述我访问帖子页面时遇到奇怪的错误.我制作了一个可以发布图像和视频的Web应用程序.使用图像它工作正常,但当我发布视频并转到其页面时,服务器给我以下输出: Traceback (most recent call last): File "C:\Users\Slavko\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py 我访问帖子页面时遇到奇怪的错误.我制作了一个可以发布图像和视频的Web应用程序.使用图像它工作正常,但当我发布视频并转到其页面时,服务器给我以下输出:

Traceback (most recent call last):  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\wsgiref\handlers.py",line 138,in run    self.finish_response()  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\wsgiref\handlers.py",line 180,in finish_response    self.write(data)  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\wsgiref\handlers.py",line 279,in write    self._write(data)  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\wsgiref\handlers.py",line 453,in _write    self.stdout.write(data)  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\socket.py",line 593,in write    return self._sock.send(b)ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine[15/May/2016 13:50:09] "GET /media/uploads/Big_Buck_Bunny_Final.mp4 http/1.1" 500 59----------------------------------------Exception happened during processing of request from ('127.0.0.1',23943)[15/May/2016 13:50:09] "GET /static/image/vIDeo-poster.jpg http/1.1" 304 0Traceback (most recent call last):  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\wsgiref\handlers.py",in write    return self._sock.send(b)ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machineDuring handling of the above exception,another exception occurred:Traceback (most recent call last):  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\wsgiref\handlers.py",line 141,in run    self.handle_error()  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\site-packages\django\core\servers\basehttp.py",line 92,in handle_error    super(ServerHandler,self).handle_error()  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\wsgiref\handlers.py",line 368,in handle_error    self.finish_response()  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\wsgiref\handlers.py",line 274,in write    self.send_headers()  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\wsgiref\handlers.py",line 331,in send_headers    if not self.origin_server or self.clIEnt_is_modern():  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\wsgiref\handlers.py",line 344,in clIEnt_is_modern    return self.environ['SERVER_PROTOCol'].upper() != 'http/0.9'TypeError: 'nonetype' object is not subscriptableDuring handling of the above exception,another exception occurred:Traceback (most recent call last):  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\socketserver.py",line 628,in process_request_thread    self.finish_request(request,clIEnt_address)  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\socketserver.py",line 357,in finish_request    self.RequestHandlerClass(request,clIEnt_address,self)  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\site-packages\django\core\servers\basehttp.py",line 99,in __init__    super(WsgiRequestHandler,self).__init__(*args,**kwargs)  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\socketserver.py",line 684,in __init__    self.handle()  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\site-packages\django\core\servers\basehttp.py",line 179,in handle    handler.run(self.server.get_app())  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\wsgiref\handlers.py",line 144,in run    self.close()  file "C:\Users\Slavko\AppData\Local\Programs\Python\python35-32\lib\wsgiref\simple_server.py",line 35,in close    self.status.split(' ',1)[0],self.bytes_sentAttributeError: 'nonetype' object has no attribute 'split'

图像和视频的代码是相同的,这就是为什么我不明白这一点.
这是我的查看功能,当您访问帖子页面时使用:

def post_info(request,pk):    form = CommentForm(request.POST or None)    post = get_object_or_404(Post,pk=pk)    same_author_posts = Post.objects.filter(author=post.author)    if request.method == 'POST':        if form.is_valID():            instance = form.save(commit=False)            instance.author = request.user            instance.post = post            instance.save()            form = CommentForm()            messages.success(request,'Comment is approved!')            return httpResponseRedirect('/post/%s/'%(pk))        else:            messages.error(request,'Comment is not valID!')            return httpResponseRedirect('/post/%s/'%(pk))    context = {        'form': form,'post': post,'same_author_posts': same_author_posts,}    return render(request,'post/post_info.HTML',context)

可能它在响应中有状态代码,但为什么它不会在加载图像时显示它以及如何修复它?

解决方法 尝试在禁用防火墙/防病毒的情况下运行它 总结

以上是内存溢出为你收集整理的Django(Python)AttributeError:’NoneType’对象没有属性’split’全部内容,希望文章能够帮你解决Django(Python)AttributeError:’NoneType’对象没有属性’split’所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1196131.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存