0

{% thumbnail photo.image 300x170 %}我使用easy_thumbnails,它在开发机器上运行良好,但在生产中,当我使用templatetag时,我得到如下所示的错误。

虽然可以直接浏览http: //sitename.com/media/uploads/2012/09/13/ microsoft1.jpeg`。媒体设置正确并且上传被放置在正确的位置,缺少什么然后可能是什么问题?

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

模型

ThumbnailerImageFieldeasy_thumbnails被使用

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 方法时它失败了

>>> 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
4

1 回答 1

1

问题是因为默认情况下pip install PIL,我的 Webfaction 实例是libjpeg这样链接的,并pip install PIllow遵循http://community.webfaction.com/questions/7340/how-to-install-pil-with-truetype-support上的文章

于 2012-09-13T16:50:54.590 回答