生产中的唯一缩略图+ Django问题 [英] sorl thumbnail + django issues in production

查看:70
本文介绍了生产中的唯一缩略图+ Django问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Django中使用单一缩略图.在我的本地设置中,它工作正常,但在生产中未制作缩略图.

I'm using sorl thumbnail with Django. On my local setup it works fine, but in production the thumbnails are not made.

我的代码如下:

{% load thumbnail %}
{% thumbnail up.image "32x32" crop="center" as im %}
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% empty %}
<img src="{{ MEDIA_URL }}/images/missing_small.png" alt="" title="" />
{% endthumbnail %}

我启用了日志记录,跟踪显示如下:

I enabled logging and the trace looks like this:

Traceback (most recent call last):

[...]

File "/usr/local/lib/python2.6/dist-packages/PIL/ImageFile.py", line
215, in load
raise_ioerror(e)

File "/usr/local/lib/python2.6/dist-packages/PIL/ImageFile.py", line
52, in raise_ioerror
raise IOError(message + " when reading image file")

IOError: broken data stream when reading image file

该错误不是很有帮助,因为该文件已存在并且所有人都可以读取.我不确定如何获取更明确的错误,或尝试解决的问题.

The error isn't very helpful since the file is there and is readable by all. I'm not sure how to get a more explicit error, or what to try and fix.

然后更令人困惑的是它使用manage.py shell

And then more baffling is the fact that it works using manage.py shell

In [1]: from sorl.thumbnail import get_thumbnail

In [2]: im = get_thumbnail('/myproject/static/images/user_profiles/1/11-20-2010-2_5.jpg',
'32x32', crop='center' )

In [3]: im
Out[3]: <sorl.thumbnail.images.ImageFile object at 0x29fe090>

In [4]: im.url
Out[4]: 'http://example.com/cache/ff/31/ff318b4a995ff345d1d48e79b67ec62b.jpg'

它制作了缩略图,只是无法通过模板代码制作.

It made the thumbnail, just won't make one via the template code.

有人吗?

推荐答案

尝试了所有内容.最终通过更新的Linux发行版解决了自己.在Ubuntu 10.04上无法使用,但之后对我,11.04、11.10等都可以正常工作.

Tried everything. Ended up solving itself with a newer Linux distro. Wouldn't work on Ubuntu 10.04 but after that it works fine for me, 11.04, 11.10, etc.

这篇关于生产中的唯一缩略图+ Django问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆