【问题标题】:Error on display static content显示静态内容时出错
【发布时间】:2011-04-29 18:39:42
【问题描述】:

我有一个带有静态图像的模板。每次调用此页面时,图像都不会显示,并且我会在控制台中收到下一个错误:

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)
----------------------------------------

我该如何解决?

【问题讨论】:

    标签: python django static


    【解决方案1】:

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

    【讨论】:

    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        猜你喜欢
        • 2014-09-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-03-24
        相关资源
        最近更新 更多