问题
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
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)
Update
I did investigation from Django's management shell and get_thumbnailer
function works fine
>>> 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'
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
回答1:
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
来源:https://stackoverflow.com/questions/12407745/webfaction-django-1-4-1-easy-thumbnails-3-0b-couldnt-get-the-thumbnail-err