0

I'm creating a website and everything was working fine until yesterday when suddenly images on the webpage stopped getting displayed. The server seems to GET the images but they are not getting displayed and I can't figure out why. When I load the webpage, I get a placeholder for the image like its going to load but then it goes away.

These are my configurations:

settings.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/'

I'm using sorl-thumbnail, a django package for displaying images. Using this, I display an image in a template like this:

template.html

{% load thumbnail %}


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

These are server messages when i load a webpage:

[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

The images were working fine before i restarted my computer. After the restart, this problem started, and along with this problem I started getting these errors:

[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

I searched for the error and found out it's something of a browser issue.

Community
  • 1
  • 1
H H H
  • 489
  • 1
  • 7
  • 20
  • Maybe try restarting your django app after memcached is running? http://stackoverflow.com/questions/2529296/broken-pipe-error-in-rails-with-memcached – garnertb Sep 14 '13 at 16:15
  • I did as per the link, but no luck. I also cleared my cache, but still not working. – H H H Sep 14 '13 at 17:01

1 Answers1

0

Oh my! All this was due to conflict in urls!

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

was conflicting with

url(r'^(?P<country_slug>[\w-]+)/', include('Locations.urls'), name= 'country'),
H H H
  • 489
  • 1
  • 7
  • 20