djangonginxdjango-admindjango-imagekitimagekit

ImageKit does not show thumbnail on Django Admin


I have deployed an ubuntu server running Django. For image thumbnailing am using PILLOW and ImageKit. When I try to save an entry the main ImageFile is saved and the thumbnail is created aswell but once I save I get a server error 500. Once I reload the same page the entry loads but shows no thumbnail and once I click on the thumbnail i get a 404 Not found on the browser.

My nginx config is below :

    upstream app_server {
    server 127.0.0.1:9000 fail_timeout=0;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 4G;
    server_name _;

    keepalive_timeout 5;

    # Your Django project's media files - amend as required
    location /media  {
        alias /home/django/django_project/media;
    }

    # your Django project's static files - amend as required
    location /static {
        alias /home/django/django_project/static;
    }

    # Proxy the static assests for the Django Admin panel


    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app_server;
    }
}

The media files ares served correctly. My question now is, shall i create another variable that points to the thumbnail path? Any ideas?

Error listed Below :

    IOError at /admin/profiles/districtheatingreference/
decoder jpeg not available
Request Method: GET
Request URL:    http://178.62.67.237/admin/profiles/districtheatingreference/
Django Version: 1.7.2
Exception Type: IOError
Exception Value:    
decoder jpeg not available
Exception Location: /usr/local/lib/python2.7/dist-packages/PIL/Image.py in _getdecoder, line 419
Python Executable:  /usr/bin/python
Python Version: 2.7.6
Python Path:    
['/home/django/django_project',
 '/home/django',
 '/usr/bin',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages']
Server time:    Tue, 5 May 2015 10:37:20 +0000
Error during template rendering

In template /usr/local/lib/python2.7/dist-packages/imagekit/templates/imagekit/admin/thumbnail.html, error at line 1
decoder jpeg not available
1   {% if thumbnail %}
2       <a href="{{ model.get_absolute_url|default:original_image.url }}">
3           <img src="{{ thumbnail.url }}">
4       </a>
5   {% endif %}

NGINX LOG :

2015/05/05 06:01:43 [error] 1185#0: *1565 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/profiles/residentialreference/"
2015/05/05 06:01:43 [error] 1185#0: *1578 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/profiles/residentialreference/"
2015/05/05 06:01:43 [error] 1185#0: *1577 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG HTTP/1.1", host: "178.62.67.237"
2015/05/05 06:01:45 [error] 1185#0: *1577 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/profiles/residentialreference/"
2015/05/05 06:01:56 [error] 1185#0: *1583 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/profiles/residentialreference/"
2015/05/05 06:02:02 [error] 1185#0: *1585 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/profiles/residentialreference/"
2015/05/05 06:02:02 [error] 1185#0: *1584 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/profiles/residentialreference/"
2015/05/05 06:02:02 [error] 1185#0: *1584 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG HTTP/1.1", host: "178.62.67.237"
2015/05/05 06:02:06 [error] 1185#0: *1584 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/profiles/residentialreference/"
2015/05/05 06:03:31 [error] 1185#0: *1590 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG HTTP/1.1", host: "178.62.67.237"
2015/05/05 06:03:36 [error] 1185#0: *1590 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/profiles/residentialreference/"
2015/05/05 06:11:21 [error] 1185#0: *1603 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/profiles/residentialreference/"
2015/05/05 06:11:25 [error] 1185#0: *1598 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/profiles/residentialreference/"
2015/05/05 06:11:25 [error] 1185#0: *1603 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/profiles/residentialreference/"
2015/05/05 06:11:25 [error] 1185#0: *1603 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_reEvISt/66ad91e0b184febc1b8b71d00e67bff0.JPG HTTP/1.1", host: "178.62.67.237"
2015/05/05 06:12:31 [error] 1185#0: *1625 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_cyxxLNn/fe87a38155418f621c48de1937234bdd.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_cyxxLNn/fe87a38155418f621c48de1937234bdd.JPG HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/profiles/residentialreference/"
2015/05/05 06:12:31 [error] 1185#0: *1624 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_cyxxLNn/fe87a38155418f621c48de1937234bdd.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_cyxxLNn/fe87a38155418f621c48de1937234bdd.JPG HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/profiles/residentialreference/"
2015/05/05 06:12:31 [error] 1185#0: *1624 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_cyxxLNn/fe87a38155418f621c48de1937234bdd.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_cyxxLNn/fe87a38155418f621c48de1937234bdd.JPG HTTP/1.1", host: "178.62.67.237"
2015/05/05 06:12:33 [error] 1185#0: *1624 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_cyxxLNn/fe87a38155418f621c48de1937234bdd.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_cyxxLNn/fe87a38155418f621c48de1937234bdd.JPG HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/profiles/residentialreference/"
2015/05/05 06:22:42 [error] 1185#0: *1656 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_xgGCGrG/9b80392126e96993a428384064177ef4.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_xgGCGrG/9b80392126e96993a428384064177ef4.JPG HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/profiles/residentialreference/"
2015/05/05 06:22:42 [error] 1185#0: *1658 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_xgGCGrG/9b80392126e96993a428384064177ef4.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_xgGCGrG/9b80392126e96993a428384064177ef4.JPG HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/profiles/residentialreference/"
2015/05/05 06:22:43 [error] 1185#0: *1652 open() "/home/django/django_project/media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_xgGCGrG/9b80392126e96993a428384064177ef4.JPG" failed (2: No such file or directory), client: 81.143.88.153, server: _, request: "GET /media/CACHE/images/images/ShanRoberts_NWales_Vitocal300A_xgGCGrG/9b80392126e96993a428384064177ef4.JPG HTTP/1.1", host: "178.62.67.237"

Solution

  • Solution found. I was missing some libraries.

    apt-get install libjpeg-dev and reinstalling pillow fixed the error!