问题描述
我使用easy_thumbnails,它在开发机器上工作正常,但在生产中,我收到错误,如下所示,当我使用 {%thumbnail photo.image 300x170%}
templatetag 。
I use easy_thumbnails and it works fine on a development machine but in production I get errors like shown below, when I use {% thumbnail photo.image 300x170 %}
templatetag.
虽然可以直接浏览`。
还有媒体设置正确,上传被放置在正确的地方,那么错误的是什么?
Though can directly browse http://sitename.com/media/uploads/2012/09/13/microsoft1.jpeg`.Also media set correctly and uploads are being placed at the right place, what is missing then what might be wrong?
File "/home/imanhodjaev/lib/python2.7/django/template/base.py" in render
823. bit = self.render_node(node, context)
File "/home/imanhodjaev/lib/python2.7/django/template/debug.py" in render_node
74. return node.render(context)
File "/home/imanhodjaev/lib/python2.7/easy_thumbnails/templatetags/thumbnail.py" in render
99. (source, e))
Exception Type: TemplateSyntaxError at /petition/microsoft-myi-hotim-kyirgyizskij-rasklad-klaviatur/update-picture
Exception Value: Couldn't get the thumbnail uploads/2012/09/13/microsoft1.jpeg: The source file does not appear to be an image
模型
ThumbnailerImageField
from easy_thumbnails
使用
Model
ThumbnailerImageField
from easy_thumbnails
is used
class Petition(models.Model):
title = models.CharField(max_length=512)
slug = models.SlugField(max_length=512, editable=False, blank=True)
description = models.TextField()
petition_text = models.TextField(blank=True, null=True)
petition_picture = ThumbnailerImageField(upload_to=get_upload_path, blank=True)
更新
我从Django的管理外壳中调查过, get_thumbnailer
功能正常
>>> thumb_url = get_thumbnailer(pet.petition_picture)
>>> thumb_url
<ThumbnailerImageFieldFile: uploads/2012/09/13/microsoft1.jpeg>
>>> thumb_url.url
'/m/uploads/2012/09/13/microsoft1.jpeg'
当我调用get thumbnail方法时,它失败
And when I call get thumbnail method it fails
>>> thumb_url = get_thumbnailer(pet.petition_picture).get_thumbnail(options)
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/home/imanhodjaev/lib/python2.7/easy_thumbnails/files.py", line 380, in get_thumbnail
thumbnail = self.generate_thumbnail(thumbnail_options)
File "/home/imanhodjaev/lib/python2.7/easy_thumbnails/files.py", line 290, in generate_thumbnail
"The source file does not appear to be an image")
InvalidImageFormatError: The source file does not appear to be an image
推荐答案
问题是因为默认情况下 pip install PIL 与 libjpeg
链接,所以 pip install PIllow
,并在
The problem was because of by default pip install PIL
on my Webfaction instance was linked with libjpeg
so did pip install PIllow
and followed the article at http://community.webfaction.com/questions/7340/how-to-install-pil-with-truetype-support
这篇关于Webfaction Django 1.4.1:easy_thumbnails 3.0b - “无法获取缩略图”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!