ImageKit不会在Django Admin上显示缩略图

时间:2015-05-05 10:25:45

标签: django nginx django-admin django-imagekit imagekit

我已经部署了一个运行Django的ubuntu服务器。对于使用PILLOW和ImageKit的图像缩略图。当我尝试保存一个条目时,保存主ImageFile并创建缩略图,但是一旦我保存,我得到服务器错误500.一旦我重新加载相同的页面,条目加载但没有显示缩略图,一旦我点击缩略图我在浏览器上找不到404。

我的nginx配置如下:

    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;
    }
}

正确提供媒体文件。我现在的问题是,我应该创建另一个指向缩略图路径的变量吗?有任何想法吗?

下面列出的错误:

    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日志:

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"

1 个答案:

答案 0 :(得分:0)

找到解决方案。我错过了一些图书馆。

apt-get install libjpeg-dev并重新安装枕头修复错误!