django:出现错误AttributeError:即使我能够访问页面,“ NoneType”对象也没有属性“ split”

时间:2019-12-19 07:40:57

标签: python django

我在运行命令时遇到错误。但是,页面正在打开,但是下面的命令提示符下出现错误。我引用了其他存在类似错误的stackflow页面,但没有帮助。

python manage.py runserver

错误:

Performing system checks...

System check identified no issues (0 silenced).
December 19, 2019 - 13:04:14
Django version 2.1.5, using settings 'first_project.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[19/Dec/2019 13:04:19] "GET / HTTP/1.1" 200 2786
[19/Dec/2019 13:04:19] "GET /static/css/mystyle.css HTTP/1.1" 200 68
Not Found: /favicon.ico
[19/Dec/2019 13:04:19] "GET /favicon.ico HTTP/1.1" 404 2211
Traceback (most recent call last):
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 138, in run
    self.finish_response()
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 180, in finish_response
    self.write(data)
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 274, in write
    self.send_headers()
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 332, in send_headers
    self.send_preamble()
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 255, in send_preamble
    ('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 453, in _write
    result = self.stdout.write(data)
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\socketserver.py", line 799, in write
    self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
[19/Dec/2019 13:04:19] "GET /favicon.ico HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 52848)
Traceback (most recent call last):
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 138, in run
    self.finish_response()
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 180, in finish_response
    self.write(data)
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 274, in write
    self.send_headers()
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 332, in send_headers
    self.send_preamble()
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 255, in send_preamble
    ('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 453, in _write
    result = self.stdout.write(data)
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\socketserver.py", line 799, in write
    self._sock.sendall(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\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 141, in run
    self.handle_error()
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\site-packages\django\core\servers\basehttp.py", line 116, in handle_error
    super().handle_error()
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 368, in handle_error
    self.finish_response()
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 180, in finish_response
    self.write(data)
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 274, in write
    self.send_headers()
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 331, in send_headers
    if not self.origin_server or self.client_is_modern():
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\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\rishbans\Anaconda3\envs\DjangoProject\lib\socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\socketserver.py", line 720, in __init__
    self.handle()
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
    self.handle_one_request()
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\site-packages\django\core\servers\basehttp.py", line 194, in handle_one_request
    handler.run(self.server.get_app())
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\handlers.py", line 144, in run
    self.close()
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\site-packages\django\core\servers\basehttp.py", line 111, in close
    super().close()
  File "C:\Users\rishbans\Anaconda3\envs\DjangoProject\lib\wsgiref\simple_server.py", line 35, in close
    self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'

任何想法,我应该研究一下。让我知道您是否需要任何特定文件。

1 个答案:

答案 0 :(得分:-1)

这仅表示self.status正在以某种方式返回值。因此,插入支票并尝试像这样:

if self.status != None:
    self.status.split(' ',1)[0]