Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 显示静态内容时出错_Python_Django_Static - Fatal编程技术网

Python 显示静态内容时出错

Python 显示静态内容时出错,python,django,static,Python,Django,Static,我有一个静态图像模板。此页面的每一次调用都不会显示图像,控制台中会出现下一个错误: Development server is running at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. [24/Oct/2010 11:25:36] "GET /index/ HTTP/1.1" 200 20058 [24/Oct/2010 11:25:36] "GET /images/logo.png HTTP/1.1" 500 6512

我有一个静态图像模板。此页面的每一次调用都不会显示图像,控制台中会出现下一个错误:

Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[24/Oct/2010 11:25:36] "GET /index/ HTTP/1.1" 200 20058
[24/Oct/2010 11:25:36] "GET /images/logo.png HTTP/1.1" 500 65126
[24/Oct/2010 11:25:37] "GET /index/ HTTP/1.1" 200 20058
[24/Oct/2010 11:25:37] "GET /images/logo.png HTTP/1.1" 200 6439
[24/Oct/2010 11:25:39] "GET /index/ HTTP/1.1" 200 20058
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 281, in run self.finish_response()
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 321, in   finish_response self.write(data)
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 417, in write
self._write(data)
  File "C:\Python27\lib\socket.py", line 322, in write
self.flush()
  File "C:\Python27\lib\socket.py", line 301, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10053] An established connection was aborted by the software in your host machine
Traceback (most recent call last):
  File "C:\Python27\lib\SocketServer.py", line 284, in _handle_request_noblock
self.process_request(request, client_address)
  File "C:\Python27\lib\SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
  File "C:\Python27\lib\SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 562, in __init__
  BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
 File "C:\Python27\lib\SocketServer.py", line 641, in __init__
self.finish()
  File "C:\Python27\lib\SocketServer.py", line 694, in finish
self.wfile.flush()
  File "C:\Python27\lib\socket.py", line 301, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10053] An established connection was aborted by the software in your host machine
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 38314)
----------------------------------------

如何修复它?

也许您有另一个使用8000端口号的应用程序。您是否尝试使用其他端口号?

这是一个与Chrome相关的问题。要停止获取这些错误,您必须取消选中Chrome设置中的“预测网络操作以提高页面加载性能”。

检查您是否从视图中提供了请求上下文。在我的例子中,这种情况发生在{STATIC_URL}}丢失时,它丢失是因为我忘了向render_to_response()函数添加请求上下文。

我更改了端口号,但遇到了相同的问题。不知道这是否能帮助您解决问题,但请检查此链接:您是否使用其他服务器,例如Apache服务器?如果是,那么您是否遇到相同的问题?不,我不使用其他服务器。这是我对类似问题的回答:。