mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #6054: work around PIL's installation brokeness by detecting either of the two ways it can end up being installed.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12429 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -30,7 +30,12 @@ class ImageFile(File):
|
||||
|
||||
def get_image_dimensions(file_or_path):
|
||||
"""Returns the (width, height) of an image, given an open file or a path."""
|
||||
from PIL import ImageFile as PILImageFile
|
||||
# Try to import PIL in either of the two ways it can end up installed.
|
||||
try:
|
||||
from PIL import ImageFile as PILImageFile
|
||||
except ImportError:
|
||||
import ImageFile as PILImageFile
|
||||
|
||||
p = PILImageFile.Parser()
|
||||
close = False
|
||||
if hasattr(file_or_path, 'read'):
|
||||
|
||||
@@ -47,10 +47,14 @@ def get_validation_errors(outfile, app=None):
|
||||
if isinstance(f, models.FileField) and not f.upload_to:
|
||||
e.add(opts, '"%s": FileFields require an "upload_to" attribute.' % f.name)
|
||||
if isinstance(f, models.ImageField):
|
||||
# Try to import PIL in either of the two ways it can end up installed.
|
||||
try:
|
||||
from PIL import Image
|
||||
except ImportError:
|
||||
e.add(opts, '"%s": To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .' % f.name)
|
||||
try:
|
||||
import Image
|
||||
except ImportError:
|
||||
e.add(opts, '"%s": To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .' % f.name)
|
||||
if isinstance(f, models.BooleanField) and getattr(f, 'null', False):
|
||||
e.add(opts, '"%s": BooleanFields do not accept null values. Use a NullBooleanField instead.' % f.name)
|
||||
if f.choices:
|
||||
|
||||
Reference in New Issue
Block a user