我使用django-imagekit处理上传图像,并遇到以下错误:
AttributeError at /car/7/
'cStringIO.StringO' object has no attribute 'fileno'
Request Method: GET
Request URL: http://luxingnan.azurewebsites.net/car/7/
Django Version: 1.8
Exception Type: AttributeError
Exception Value:
'cStringIO.StringO' object has no attribute 'fileno'
Exception Location: D:\home\site\wwwroot\env\Lib\site-packages\pilkit\utils.py in
__enter__, line 248
Python Executable: D:\Python27\python.exe
Python Version: 2.7.8
Python Path:
[u'D:\\home\\site\\wwwroot\\env\\Lib\\site-packages', '.', 'D:\\Windows\\SYSTEM32\\python27.zip', 'D:\\Python27\\DLLs', 'D:\\Python27\\lib', 'D:\\Python27\\lib\\plat-win', 'D:\\Python27\\lib\\lib-tk', 'D:\\Python27', 'D:\\Python27\\lib\\site-packages', 'D:\\home\\site\\wwwroot']
Server time: Thu, 16 Apr 2015 12:28:26 +0000下面是我的代码:
# models.py
class Carpic(models.Model):
picture = models.ImageField('pic',upload_to='car-pictures')
picture_slide = ImageSpecField(source='picture',
processors=[ResizeToFill(762, 456)],
format='JPEG',
options={'quality': 60}
)
# template.html
{% for pic in pictures %}
<li><img src="{{pic.picture_slide.url}}"/></li>
{% endfor %}有人能告诉我该怎么做吗?谢谢
发布于 2015-04-20 18:20:03
刚刚有机会看看这个(和你的GH问题)。我将在这里列出我的回应,因为这样做似乎是正确的--明智的做法(:
看起来这是Azure的一个怪癖,但我们肯定可以在PILKit中修复它。 PILKit有实用程序来平息皮尔的一些噪音。它这样做的方式是临时更换stderr (使用它的文件描述符)。显然,在Azure上,stderr是StringIO的一个实例(它没有文件描述符)。我们只需为这种情况下的实用程序添加一个保护程序(就像当dev/null不可写时的实用程序一样)。这是个小零钱,但我现在很忙。公关将是非常感谢的!
因此,换句话说,这不是FileWrapper的问题(如评论中所建议的),而是Azure的假stderr和PILKit的quiet实用程序的组合。
https://stackoverflow.com/questions/29675103
复制相似问题