0

我正在创建一个网站,一切正常,直到昨天突然网页上的图像停止显示。服务器似乎获取了图像,但它们没有显示出来,我不知道为什么。当我加载网页时,我得到了一个图像的占位符,就像它要加载一样,但随后它就消失了。

这些是我的配置:

设置.py

CACHES = {
    'default' : {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '127.0.0.1:11211',
    }
}

MEDIA_ROOT = '/home/hammad/virt_env/virt1/gccFishing/media'

MEDIA_URL = '/media/'

我正在使用 sorl-thumbnail,一个用于显示图像的 django 包。使用它,我在这样的模板中显示图像:

模板.html

{% load thumbnail %}


{% thumbnail  user.image "200x200" crop="center" as im %}
       <img src="{{im.url}}" width="{{ im.width }}" height="{{ im.height }}">
    {% endthumbnail %}  

这些是我加载网页时的服务器消息:

[14/Sep/2013 15:41:45] "GET / HTTP/1.1" 200 159218
[14/Sep/2013 15:41:45] "GET /media/cache/c0/17/c017021609e735bdc53f402ae6009bae.jpg HTTP/1.1" 200 155657
[14/Sep/2013 15:41:47] "GET /saudi-arabia/ HTTP/1.1" 200 284186
[14/Sep/2013 15:41:47] "GET /media/cache/e9/25/e925347688cc973ecc997f00b6ee0b83.jpg HTTP/1.1" 200 156198
[14/Sep/2013 15:41:47] "GET /media/cache/a4/ac/a4aca3c7a23aeada770062e9519a8daa.jpg HTTP/1.1" 200 156731
[14/Sep/2013 15:41:47] "GET /media/cache/0a/21/0a2118ecac84d6451f3dd39cd881d8bb.jpg HTTP/1.1" 200 156728

在我重新启动计算机之前,图像工作正常。重启后,这个问题开始了,伴随着这个问题,我开始收到这些错误:

[14/Sep/2013 15:41:48] "GET /media/cache/0a/21/0a2118ecac84d6451f3dd39cd881d8bb.jpg HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 46531)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 593, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/home/hammad/virt_env/virt1/local/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 150, in __init__
    super(WSGIRequestHandler, self).__init__(*args, **kwargs)
  File "/usr/lib/python2.7/SocketServer.py", line 651, in __init__
    self.finish()
  File "/usr/lib/python2.7/SocketServer.py", line 710, in finish
    self.wfile.close()
  File "/usr/lib/python2.7/socket.py", line 279, in close
    self.flush()
  File "/usr/lib/python2.7/socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe

我搜索了错误,发现它是浏览器问题。

4

1 回答 1

0

天啊!这一切都是由于网址冲突!

(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),

url(r'^(?P<country_slug>[\w-]+)/', include('Locations.urls'), name= 'country'),
于 2013-09-14T17:06:56.687 回答