Ich bekomme seltsamen Fehler, wenn ich die Post-Seite besuche. Ich mache Web-Anwendung, wo Sie Bilder und Videos veröffentlichen können. Mit Bildern arbeitet, um es in Ordnung, aber wenn ich ein Video posten und gehe auf seine Seite, Server geben Sie mir folgende Ausgabe:Django (Python) AttributeError: 'NoneType' -Objekt hat kein Attribut 'Split'
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 0
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
During 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 180, in finish_response
self.write(data)
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 subscriptable
During 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_sent
AttributeError: 'NoneType' object has no attribute 'split'
-Code für Bilder und Videos ist das gleiche, und das ist Grund, warum ich das nicht verstehen. Hier ist meine Ansicht Funktion, die verwendet wird, wenn Sie Post-Seite besuchen:
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)
es etwas mit dem Statuscode haben wahrscheinlich in respons, aber warum sie es nicht mehr anzeigen, wenn Bilder geladen und wie kann es sein Fest?
Haben Sie die Berechtigungen des Verzeichnisses überprüft, in dem Sie die Datei speichern? – sprksh
Ja, alles ist normal. Ich stelle fest, dass manchmal der gleiche Fehler auftritt, wenn zum Beispiel 127.0.0.1:8000 zu 127.0.0.1:9000 geändert wird. Aber ich kann immer noch verstehen, warum er das nicht zeigt, wenn ich zu post_info.html gehe, um das Bild zu sehen, nur Videoausgabefehler. –
was hast du gefunden?): Ich habe den gleichen Fehler – FeanDoe