当网站运行良好时,为什么会出现此错误(AttributeError:“ NoneType”对象没有属性“ split”)?

时间:2019-09-04 16:52:43

标签: django python-3.x

我正在学习Django几个月。目前,我正在进行一个有关教师的演示项目。工作了几天后,我受不了编程知识的限制。突然我发现控制台上出现错误( AttributeError:'NoneType'对象没有属性'split'),但是我不知道它何时发生。尽管我的网站在开发服务器上运行得很好,但是此问题也在后台运行。我在Ubuntu 18.04上使用Django 2.2.4 python 3.6和Postgresql 11.0。你们能帮我摆脱这个问题吗?预先感谢!

我已经在网上搜索了解决方案,但找不到任何合适的解决方案。请大家检查下面的错误。

python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
September 04, 2019 - 16:28:55
Django version 2.2.4, using settings 'teacher_project.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[04/Sep/2019 16:31:05] "GET / HTTP/1.1" 200 6092
[04/Sep/2019 16:31:05] "GET /static/css/all_pass.css HTTP/1.1" 200 17
[04/Sep/2019 16:31:05] "GET /static/css/style.css HTTP/1.1" 200 12488
[04/Sep/2019 16:31:05] "GET /static/css/navbar.css HTTP/1.1" 200 567
[04/Sep/2019 16:31:05] "GET /static/css/font.css HTTP/1.1" 200 5483
[04/Sep/2019 16:31:05] "GET /static/img/headshot.jpg HTTP/1.1" 200 27864
[04/Sep/2019 16:31:06] "GET /static/font/SolaimanLipi.woff HTTP/1.1" 200 96104
Not Found: /favicon.ico
[04/Sep/2019 16:31:06] "GET /favicon.ico HTTP/1.1" 404 2509
[04/Sep/2019 16:31:21] "GET /media/videos/2019/09/03/Introduction_to_Calculus_1_of_2-_Seeing_the_big_picture.mp4 HTTP/1.1" 200 11124736
Traceback (most recent call last):
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 279, in write
    self._write(data)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 453, in _write
    result = self.stdout.write(data)
  File "/usr/lib/python3.6/socketserver.py", line 803, in write
    self._sock.sendall(b)
ConnectionResetError: [Errno 104] Connection reset by peer
[04/Sep/2019 16:31:21] "GET /media/videos/2019/09/03/Introduction_to_Calculus_1_of_2-_Seeing_the_big_picture.mp4 HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 49666)
[04/Sep/2019 16:31:21] "GET /media/videos/2019/09/03/Addition_of_Numbers_with_Carrying_-_Maths_For_Class_2_-_Maths_Basics_F_DvzezAP.mp4 HTTP/1.1" 200 10665984
Traceback (most recent call last):
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 279, in write
    self._write(data)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 453, in _write
    result = self.stdout.write(data)
  File "/usr/lib/python3.6/socketserver.py", line 803, in write
    self._sock.sendall(b)
ConnectionResetError: [Errno 104] Connection reset by peer
[04/Sep/2019 16:31:21] "GET /media/videos/2019/09/03/Addition_of_Numbers_with_Carrying_-_Maths_For_Class_2_-_Maths_Basics_F_DvzezAP.mp4 HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 49664)
Traceback (most recent call last):
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 138, in run
    self.finish_response()
Traceback (most recent call last):
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 279, in write
    self._write(data)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 453, in _write
    result = self.stdout.write(data)
  File "/usr/lib/python3.6/socketserver.py", line 803, in write
    self._sock.sendall(b)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 141, in run
    self.handle_error()
  File "/home/coduser/Desktop/teacher/myvenv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 116, in handle_error
    super().handle_error()
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 368, in handle_error
    self.finish_response()
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 274, in write
    self.send_headers()
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 331, in send_headers
    if not self.origin_server or self.client_is_modern():
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 344, in client_is_modern
    return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 279, in write
    self._write(data)
[04/Sep/2019 16:31:21] "GET /media/videos/2019/09/03/Algebra_Basics-_What_Is_Algebra_-_Math_Antics.mp4 HTTP/1.1" 200 11190272
TypeError: 'NoneType' object is not subscriptable
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 453, in _write
    result = self.stdout.write(data)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/socketserver.py", line 803, in write
    self._sock.sendall(b)
Traceback (most recent call last):
  File "/usr/lib/python3.6/socketserver.py", line 654, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python3.6/socketserver.py", line 364, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.6/socketserver.py", line 724, in __init__
    self.handle()
  File "/home/coduser/Desktop/teacher/myvenv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 171, in handle
    self.handle_one_request()
  File "/home/coduser/Desktop/teacher/myvenv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 194, in handle_one_request
    handler.run(self.server.get_app())
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 144, in run
    self.close()
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 279, in write
    self._write(data)
ConnectionResetError: [Errno 104] Connection reset by peer
  File "/home/coduser/Desktop/teacher/myvenv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 111, in close
    super().close()
  File "/usr/lib/python3.6/wsgiref/simple_server.py", line 35, in close
    self.status.split(' ',1)[0], self.bytes_sent

During handling of the above exception, another exception occurred:

  File "/usr/lib/python3.6/wsgiref/handlers.py", line 453, in _write
    result = self.stdout.write(data)
AttributeError: 'NoneType' object has no attribute 'split'
Traceback (most recent call last):
----------------------------------------
  File "/usr/lib/python3.6/socketserver.py", line 803, in write
    self._sock.sendall(b)
ConnectionResetError: [Errno 104] Connection reset by peer
[04/Sep/2019 16:31:21] "GET /media/videos/2019/09/03/Algebra_Basics-_What_Is_Algebra_-_Math_Antics.mp4 HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 49658)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 141, in run
    self.handle_error()
Traceback (most recent call last):
  File "/home/coduser/Desktop/teacher/myvenv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 116, in handle_error
    super().handle_error()
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 279, in write
    self._write(data)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 453, in _write
    result = self.stdout.write(data)
  File "/usr/lib/python3.6/socketserver.py", line 803, in write
    self._sock.sendall(b)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 368, in handle_error
    self.finish_response()
ConnectionResetError: [Errno 104] Connection reset by peer
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)

During handling of the above exception, another exception occurred:

  File "/usr/lib/python3.6/wsgiref/handlers.py", line 274, in write
    self.send_headers()
Traceback (most recent call last):
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 331, in send_headers
    if not self.origin_server or self.client_is_modern():
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 141, in run
    self.handle_error()
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 344, in client_is_modern
    return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
  File "/home/coduser/Desktop/teacher/myvenv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 116, in handle_error
    super().handle_error()
TypeError: 'NoneType' object is not subscriptable
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 368, in handle_error
    self.finish_response()

During handling of the above exception, another exception occurred:

  File "/usr/lib/python3.6/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
Traceback (most recent call last):
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 274, in write
    self.send_headers()
  File "/usr/lib/python3.6/socketserver.py", line 654, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 331, in send_headers
    if not self.origin_server or self.client_is_modern():
  File "/usr/lib/python3.6/socketserver.py", line 364, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 344, in client_is_modern
    return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
  File "/usr/lib/python3.6/socketserver.py", line 724, in __init__
    self.handle()
TypeError: 'NoneType' object is not subscriptable
  File "/home/coduser/Desktop/teacher/myvenv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 171, in handle
    self.handle_one_request()

During handling of the above exception, another exception occurred:

  File "/home/coduser/Desktop/teacher/myvenv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 194, in handle_one_request
    handler.run(self.server.get_app())
Traceback (most recent call last):
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 144, in run
    self.close()
  File "/usr/lib/python3.6/socketserver.py", line 654, in process_request_thread
    self.finish_request(request, client_address)
  File "/home/coduser/Desktop/teacher/myvenv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 111, in close
    super().close()
  File "/usr/lib/python3.6/wsgiref/simple_server.py", line 35, in close
    self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
  File "/usr/lib/python3.6/socketserver.py", line 364, in finish_request
    self.RequestHandlerClass(request, client_address, self)
----------------------------------------
  File "/usr/lib/python3.6/socketserver.py", line 724, in __init__
    self.handle()
  File "/home/coduser/Desktop/teacher/myvenv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 171, in handle
    self.handle_one_request()
  File "/home/coduser/Desktop/teacher/myvenv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 194, in handle_one_request
    handler.run(self.server.get_app())
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 144, in run
    self.close()
  File "/home/coduser/Desktop/teacher/myvenv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 111, in close
    super().close()
  File "/usr/lib/python3.6/wsgiref/simple_server.py", line 35, in close
    self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
----------------------------------------

嵌入式视频的HTML代码

{% extends 'base.html' %}
{% load static %}

{% block content %}



<a class="skip-link screen-reader-text" href="#content">Skip to content</a>

<!-- <div class="badge"></div> -->

<main id="content" class="main-area">

    {% for post in posts %}
    <section class="main-content">
        <div class="teacher-student">
            <div class="teacher">
                <img src="{% static 'img/headshot.jpg' %}" alt="">
                <!-- <p>TEACHER</p> -->
                <a href="user_profile.html">{{ post.author.get_full_name }}</a>
                <small>{{ post.publish }}</small>
            </div>
            <div class="available">
                {% if post.is_available %}                    
                        <a href="#">Teacher Available</a>
                {% endif %}                
            </div>

        </div>

        <div class="main-article">
            <a href="detail.html">
                <h1>{{ post.title }}</h1>
            </a>
            <video playsinline oncontextmenu="return false;" controls preload="metadata" controlsList="nodownload"
                disablePictureInPicture src="{{ post.clip.url}}" type='video/mp4'>

            </video>

            <article>
                <p>
                    Lorem ipsum dolor sit amet consectetur, adipisicing elit. Asperiores magni eveniet
                    praesentium esse molestias iusto doloremque ducimus nobis ex hic. Natus, ipsum...
                </p>
            </article>
            <div class="total-like-share">
                <p class="like"><span>Like 400</span></p>
                <p class="share"><span>Comments 4000</span></p>
            </div>

        </div>

    </section>
    {% endfor %}

</main>


<!-- Left Side Bar -->
<aside class="sidebar-left">
    <div class="left-sidebar">
        <h2 class="left-sidebar-title">Result Board</h2>
        <div class="updates-contens">
            <p><a href="#">Recent Results</a></p>
            <p><a href="#">Old Results</a></p>            
        </div>
    </div>


</aside>

<!-- Right Side Bar -->
<aside class="sidebar-right">
    <div class="right-sidebar">
        <h2 class="right-sidebar-title">Post Updates</h2>
        <div class="updates-contens">
            <p><a href="#">Latest Posts</a></p>
            <p><a href="#">Most comented posts</a></p>
            <p><a href="#">Most shared posts</a></p>
        </div>

    </div>
</aside>

{% endblock content %}

0 个答案:

没有答案