Я прочитал несколько вопросов, подобных этому. Тем не менее, их проблема была broken pipe
, что не относится к моему вопросу. Буду признателен за вашу помощь. Я пытаюсь подать видео файл в шаблоне html, используя django. Модель выглядит так:
Class Foo(models.Model):
...
video_link = models.FileField(upload_to="videos", blank=True, null=True)
....
# more fields go here
Каталог "videos" определен в разделе media, а корневой каталог определяется в настройках. Изображения, например, обслуживаются без исключения.
В шаблоне HTML я использую этот код:
<video width="100%" height="300" controls>
<source src="{{ lesson.video_link.url }}" type="video/mp4">
<source src="{{ lesson.video_link.url }}" type="video/ogg">
Your browser does not support the video tag.
</video>
Когда я нажимаю на URL видео, оно воспроизводится, но я получаю следующее исключение. Я выкладываю полный стек:
[12/Apr/2019 22:17:31] "GET /media/videos/test_video.mp4 HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('192.168.0.108', 41410)
Traceback (most recent call last):
File "/usr/lib64/python3.6/wsgiref/handlers.py", line 138, in run
self.finish_response()
File "/usr/lib64/python3.6/wsgiref/handlers.py", line 180, in finish_response
self.write(data)
File "/usr/lib64/python3.6/wsgiref/handlers.py", line 279, in write
self._write(data)
File "/usr/lib64/python3.6/wsgiref/handlers.py", line 453, in _write
result = self.stdout.write(data)
File "/usr/lib64/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/lib64/python3.6/wsgiref/handlers.py", line 141, in run
self.handle_error()
File "/home/mohammed/PycharmProjects/myproject/venv/lib64/python3.6/site-packages/django/core/servers/basehttp.py", line 116, in handle_error
super().handle_error()
File "/usr/lib64/python3.6/wsgiref/handlers.py", line 368, in handle_error
self.finish_response()
File "/usr/lib64/python3.6/wsgiref/handlers.py", line 180, in finish_response
self.write(data)
File "/usr/lib64/python3.6/wsgiref/handlers.py", line 274, in write
self.send_headers()
File "/usr/lib64/python3.6/wsgiref/handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "/usr/lib64/python3.6/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 "/usr/lib64/python3.6/socketserver.py", line 654, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib64/python3.6/socketserver.py", line 364, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib64/python3.6/socketserver.py", line 724, in __init__
self.handle()
File "/home/mohammed/PycharmProjects/myproject/venv/lib64/python3.6/site-packages/django/core/servers/basehttp.py", line 171, in handle
self.handle_one_request()
File "/home/mohammed/PycharmProjects/myproject/venv/lib64/python3.6/site-packages/django/core/servers/basehttp.py", line 194, in handle_one_request
handler.run(self.server.get_app())
File "/usr/lib64/python3.6/wsgiref/handlers.py", line 144, in run
self.close()
File "/home/mohammed/PycharmProjects/myproject/venv/lib64/python3.6/site-packages/django/core/servers/basehttp.py", line 111, in close
super().close()
File "/usr/lib64/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'
----------------------------------------
Любая помощь высоко ценится.