如何使用枕头与Django [英] How to use Pillow with Django

查看:87
本文介绍了如何使用枕头与Django的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了枕头,现在想在Django上使用它网站允许通过我的管理页面上传图像。请参阅以前的问题

I installed Pillow and now want to use it on my Django site to allow uploading of images of through my admin page. See previous question.

我需要在我的设置文件或Django的其他位置进行什么更改以识别Pillow,并允许ImageField正确上传图像?

What changes do I need to make in my settings file or elsewhere for Django to recognize Pillow and to allow the ImageField to upload the image properly?

推荐答案

问题是现在的进口工作与Pillow对PIL的工作略有不同。差异在此描述: http://pillow.readthedocs.org /en/latest/porting-pil-to-pillow.html

The problem is that imports now work slightly differently with Pillow vs PIL. The differences are described here: http://pillow.readthedocs.org/en/latest/porting-pil-to-pillow.html

Django现在已经更改为喜欢枕头超过PIL,通过这张票(< a href =https://code.djangoproject.com/ticket/19934 =nofollow> https://code.djangoproject.com/ticket/19934 )

Django has also now been changed to prefer Pillow over PIL, via this ticket (https://code.djangoproject.com/ticket/19934)

这个提交存在于新的Django 1.6a1版本中,所以新的行为将出现在Django 1.6版本中。然而,现在看来,您可以使用一个称为Pillow-PIL的新库(最初于2013年5月20日发布),该库将提供兼容性层。这可以通过以下方式轻松安装: pip install --pre Pillow-PIL

This commit is present in the new Django 1.6a1 release, so the new behaviour will be present in the Django 1.6 release. For now, however, it appears that you can use a new library (initially released May 20, 2013) called Pillow-PIL which will provide a compatibility layer. This can be easily installed with pip via: pip install --pre Pillow-PIL

这篇关于如何使用枕头与Django的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆