'NoneType' object has no attribute 'split' : Django 1.11
我正在使用pycharm在django上开展一个项目。
我在views.py中有这个视图:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 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, }) |
当我点击运行此方法的页面时,一切正常,但是我收到错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | 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。
有一些条件,您的方法返回
您需要始终确保从视图方法返回一些内容。 您也不需要
使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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, }) |
我认为这个问题与数据库有关。 主要是SQLite。
当您使用DB进行任何更改并且忘记提交或还原它时,数据库将进入锁定模式,即您遇到此问题的时间。 转到您的数据库并恢复或提交更改以解锁它,一切都将恢复正常。
https://docs.djangoproject.com/en/2.1/topics/db/transactions/