gpt4 book ai didi

python - 属性错误 : 'cStringIO.StringO' object has no attribute 'fileno' when using django-imagekit

转载 作者:太空宇宙 更新时间:2023-11-04 05:52:14 25 4
gpt4 key购买 nike

我正在使用 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 %}

谁能告诉我我该怎么做?谢谢

最佳答案

刚刚有机会看到这个(和 your GH Issue )。我会在这里包括我的回应,因为这似乎是明智之举(:

So it looks like this is a quirk of Azure but we can definitely fix it in PILKit.

PILKit has a utility for quieting some of PIL's noise. The way it does this is by temporarily replacing stderr (using its file descriptor). Apparently on Azure, stderr is an instance of StringIO (which doesn't have a file descriptor). We'll just have to add a guard to the utility for that case (just like the one for when dev/null isn't writeable). It's a small change but I'm pretty busy at the moment. A PR would be much appreciated!

因此,换句话说,这不是 FileWrapper 的问题(如评论中所建议的),而是 Azure 的假标准错误和 PILKit 的 quiet 实用程序的组合。

关于python - 属性错误 : 'cStringIO.StringO' object has no attribute 'fileno' when using django-imagekit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29675103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com