- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 pycharm 在 django 中开发一个项目。我在 views.py 中有这个 View :
def all_songs(request, filter_by):
if not request.user.is_authenticated():
return render(request, 'music/login.html')
else:
try:
song_ids = []
for album in Album.objects.all():
for song in album.song_set.all():
song_ids.append(song.pk)
users_songs = Song.objects.filter(pk__in=song_ids)
for album in GenericAlbum.objects.all():
for song in album.genericsong_set.all():
song_ids.append(song.pk)
generic_songs = GenericSong.objects.filter(pk__in=song_ids)
except Album.DoesNotExist:
users_songs = []
except GenericAlbum.DoesNotExist:
generic_songs = []
return render(request, 'music/songs.html', {
'song_list_all': users_songs,
'generic_song_list': generic_songs,
'filter_by': filter_by,
})
当我点击运行此方法的页面时,一切正常,但出现错误:
Traceback (most recent call last):
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 696, in __init__
self.handle()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 155, in handle
handler.run(self.server.get_app())
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 144, in run
self.close()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-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'
----------------------------------------
[12/Oct/2017 14:57:50] "GET /media/Eminem_-_Mockingbird.mp3 HTTP/1.1" 200 212992
Traceback (most recent call last):
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 279, in write
self._write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] Une connexion établie a été abandonnée par un logiciel de votre ordinateur hôte
[12/Oct/2017 14:57:50] "GET /media/Eminem_-_Mockingbird.mp3 HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 59866)
Traceback (most recent call last):
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 279, in write
self._write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] Une connexion établie a été abandonnée par un logiciel de votre ordinateur hôte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 88, in handle_error
super(ServerHandler, self).handle_error()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-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\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 696, in __init__
self.handle()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 155, in handle
handler.run(self.server.get_app())
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 144, in run
self.close()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-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'
----------------------------------------
[12/Oct/2017 14:57:50] "GET /media/Scorpions_-_Wind_Of_Change.mp3 HTTP/1.1" 200 1638400
[12/Oct/2017 14:57:50] "GET /media/The_Cranberries_-_Zombie.mp3 HTTP/1.1" 200 1597440
[12/Oct/2017 14:57:50] "GET /media/Bon_Jovi_-_Always.mp3 HTTP/1.1" 200 1449984
Traceback (most recent call last):
Traceback (most recent call last):
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 279, in write
self._write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
[12/Oct/2017 14:57:50] "GET /media/Bon_Jovi_-_Hey_God_Long_Version.mp3 HTTP/1.1" 200 1318912
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
ConnectionResetError: [WinError 10054] Une connexion existante a dû être fermée par l’hôte distant
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 279, in write
self._write(data)
[12/Oct/2017 14:57:50] "GET /media/Scorpions_-_Wind_Of_Change.mp3 HTTP/1.1" 500 59
Traceback (most recent call last):
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
----------------------------------------
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
Traceback (most recent call last):
Exception happened during processing of request from ('127.0.0.1', 59868)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
ConnectionResetError: [WinError 10054] Une connexion existante a dû être fermée par l’hôte distant
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 279, in write
self._write(data)
[12/Oct/2017 14:57:50] "GET /media/The_Cranberries_-_Zombie.mp3 HTTP/1.1" 500 59
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 59869)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 279, in write
self._write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
ConnectionResetError: [WinError 10054] Une connexion existante a dû être fermée par l’hôte distant
ConnectionResetError: [WinError 10054] Une connexion existante a dû être fermée par l’hôte distant
[12/Oct/2017 14:57:50] "GET /media/Bon_Jovi_-_Hey_God_Long_Version.mp3 HTTP/1.1" 500 59
----------------------------------------
[12/Oct/2017 14:57:50] "GET /media/Bon_Jovi_-_Always.mp3 HTTP/1.1" 500 59
Exception happened during processing of request from ('127.0.0.1', 59871)
----------------------------------------
[12/Oct/2017 14:57:50] "GET /media/eminem__lose_yourself_lyrics.mp3 HTTP/1.1" 200 794624
Exception happened during processing of request from ('127.0.0.1', 59870)
Traceback (most recent call last):
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 279, in write
self._write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
ConnectionResetError: [WinError 10054] Une connexion existante a dû être fermée par l’hôte distant
Traceback (most recent call last):
Traceback (most recent call last):
During handling of the above exception, another exception occurred:
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
Traceback (most recent call last):
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
Traceback (most recent call last):
Traceback (most recent call last):
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 279, in write
self._write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 279, in write
self._write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 88, in handle_error
super(ServerHandler, self).handle_error()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] Une connexion établie a été abandonnée par un logiciel de votre ordinateur hôte
[12/Oct/2017 14:57:50] "GET /media/eminem__lose_yourself_lyrics.mp3 HTTP/1.1" 500 59
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
----------------------------------------
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 279, in write
self._write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 279, in write
self._write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
ConnectionResetError: [WinError 10054] Une connexion existante a dû être fermée par l’hôte distant
Exception happened during processing of request from ('127.0.0.1', 59867)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
During handling of the above exception, another exception occurred:
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
Traceback (most recent call last):
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
ConnectionResetError: [WinError 10054] Une connexion existante a dû être fermée par l’hôte distant
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-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\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 696, in __init__
self.handle()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 155, in handle
handler.run(self.server.get_app())
During handling of the above exception, another exception occurred:
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
ConnectionResetError: [WinError 10054] Une connexion existante a dû être fermée par l’hôte distant
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 144, in run
self.close()
Traceback (most recent call last):
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 88, in handle_error
super(ServerHandler, self).handle_error()
During handling of the above exception, another exception occurred:
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
Traceback (most recent call last):
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
Traceback (most recent call last):
AttributeError: 'NoneType' object has no attribute 'split'
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 88, in handle_error
super(ServerHandler, self).handle_error()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 88, in handle_error
super(ServerHandler, self).handle_error()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
----------------------------------------
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 279, in write
self._write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-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
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] Une connexion établie a été abandonnée par un logiciel de votre ordinateur hôte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 88, in handle_error
super(ServerHandler, self).handle_error()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-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\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 696, in __init__
self.handle()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 155, in handle
handler.run(self.server.get_app())
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 144, in run
self.close()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-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'
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-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\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 696, in __init__
self.handle()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 155, in handle
handler.run(self.server.get_app())
----------------------------------------
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
TypeError: 'NoneType' object is not subscriptable
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 144, in run
self.close()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 696, in __init__
self.handle()
During handling of the above exception, another exception occurred:
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 155, in handle
handler.run(self.server.get_app())
Traceback (most recent call last):
AttributeError: 'NoneType' object has no attribute 'split'
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 144, in run
self.close()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address)
----------------------------------------
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 696, in __init__
self.handle()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 155, in handle
handler.run(self.server.get_app())
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 144, in run
self.close()
File "C:\Users\elmou\AppData\Local\Programs\Python\Python36-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'
----------------------------------------
AttributeError: 'NoneType' object has no attribute 'split'
----------------------------------------
我正在使用 python 3.6 运行 django 1.11。
最佳答案
在某些情况下,您的方法返回 None
,这就是您从 wsgi
堆栈中收到错误的原因。
您需要始终确保从 View 方法中返回某些内容。您也不需要 try
,因为您的任何调用都不会引发您试图捕获的异常。
使用 login_required
decorator 进一步简化并且您的方法现在更易于管理:
from django.contrib.auth.decorators import login_required
@login_required()
def all_songs(request, filter_by=None):
song_ids = []
for album in Album.objects.all():
for song in album.song_set.all():
song_ids.append(song.pk)
users_songs = Song.objects.filter(pk__in=song_ids)
for album in GenericAlbum.objects.all():
for song in album.genericsong_set.all():
song_ids.append(song.pk)
generic_songs = GenericSong.objects.filter(pk__in=song_ids)
return render(request, 'music/songs.html', {
'song_list_all': users_songs,
'generic_song_list': generic_songs,
'filter_by': filter_by,
})
关于python - 'NoneType' 对象没有属性 'split' : Django 1. 11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46695379/
在 R 中,您可以使用 strsplit在分隔符( split )上分割向量的函数如下: x <- "What is this? It's an onion. What! That's| Well
我的 .split(); 方法有问题。 我称这个函数为: get_content_ajax("html/settings.html", "#ajax", 1, "Settings page have
我是Elixir的新手。我正在尝试对字符串split的基本操作,如下所示 String.split("Awesome",""); 根据elixir document,它应该根据提供的模式split字符
当我使用 =arrayformula(split(input!G2:G, ",")) 时,为什么拆分公式没有扩展到整个列? 我只得到输入的结果!G2 单元格,而不是 G 列中的其余部分。其他公式如 =
我正在尝试制作一个名为 core-splitter 的元素,该元素在 1.0 中已弃用,因为它在我们的项目中起着关键作用。 如果您不知道 core-splitter 的作用,我可以提供一个简短的描述。
我很难尝试使用多个定界符将字符串拆分为列表。我可以像下面这样将它拆分两次: myString.split(':')[1].split('.') 然而,这看起来很不优雅。在我的脑海里,我想做这样的事情:
来自使用惊喜模块的推荐引擎的代码,我在任何地方都找不到答案。 最佳答案 根据您的目标,您可以使用 cross_validation方法,它将自动为您执行拆分。示例:cross_validate(alg
我正在制作一个有丝 split 模拟器,我希望它在细胞足够大并 split 时运行有丝 split 功能。当它分割时,我希望它能够将分割从初始 x 值(前一个单元格的 x)动画化为新的 x 值(右侧的
我有一个用于三个按钮的点击处理程序,在这个处理程序中我想提取所点击按钮的 ID。我有一行这样的代码: $('#switch button').click(function(){ var cla
我需要像这样分割一个字符串 var val = "$cs+55+mod($a)"; 放入数组 arr = val.split( /[+-/*()\s*]/ ); 问题是将分隔符保留为数组元素,如 ar
我在同一个 string 上使用 split() 和 split("") .但为什么 split("") 返回的元素数量少于 split()?我想知道在什么特定的输入情况下会发生这种情况。 最佳答案
我的代码中某处有错误,但看不到我做错了什么。 我拥有的是 facebook 用户 ID 的隐藏输入,它是通过 jQuery UI 自动完成填充的: 然后,我有一个 jQuery 函数,当单击链接将其
我正在寻找一个程序来读取字符串/文件并显示其中的前三个单词。 所以我尝试了: letter= "a,b,c" print(letter.split(',')[0]) 这对获取一个单词有效,但执行 [0
我有一个存储邮件的表 Mails(谁会想到... ;))。 通过 tinyint MailStatus,我决定这是 SentMail、Draft 还是 ReceivedMail。 现在我想知道 Tab
在我的优化探索中,我发现内置的 split() 方法比等效的 re.split() 方法快大约 40%。 虚拟基准(易于复制粘贴): import re, time, random def rando
我对split有一个奇怪的问题,因为默认情况下它不会将split放入默认数组中。 以下是一些玩具代码。 #!/usr/bin/perl $A="A:B:C:D"; split (":",$A); pr
我目前正在学习 JCL,并且正在使用 SORT 程序。作为练习,我想将一些输入记录拆分为属于同一 PDS 的多个成员。这是我的 JCL 代码: //FAILJ JOB //STEP1 EX
在苦苦挣扎了半小时之后,我在使用空格分割字符串时遇到了这种差异,具体取决于您使用的语法。 简单字符串: $line = "1: 2: 3: 4: 5: " 拆分示例1 -从1开始注意带有 token
我有一个像这样的字符串: 'Agendas / Schedules meetings and speakers 4 F 1928-1209 Box 2' 我正在尝试将其
我试图了解 r-tree 的工作原理,发现有两种类型的拆分:二次拆分和线性拆分。 线性和二次实际上有什么区别?在哪种情况下,一个会比另一个更受欢迎? 最佳答案 原始 R-Tree 论文在 3.5.2
我是一名优秀的程序员,十分优秀!