diff options
| author | Andriy Sokolovskiy <me@asokolovskiy.com> | 2015-06-16 18:24:59 +0300 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-06-16 14:38:25 -0400 |
| commit | 8abe2d0643a9ad9986e5b12644dbe0d0fc8b5f5d (patch) | |
| tree | 3a0b1df6c9e9cc7470e4fd4f4d5dba32415e26f1 /django/forms | |
| parent | 8050e6282e4daee24758a4a1c6c2fa938957bef2 (diff) | |
[1.8.x] Fixed #24948 -- Fixed crash when uploading bitmap images in forms.ImageField
Backport of cf6ce279c7671a4c83c960c5c526f92679a4fac8 from master
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/fields.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py index ebc25610ee..53520530b6 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -692,7 +692,9 @@ class ImageField(FileField): # Annotating so subclasses can reuse it for their own validation f.image = image - f.content_type = Image.MIME[image.format] + # Pillow doesn't detect the MIME type of all formats. In those + # cases, content_type will be None. + f.content_type = Image.MIME.get(image.format) except Exception: # Pillow doesn't recognize it as an image. six.reraise(ValidationError, ValidationError( |
