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:37:58 -0400 |
| commit | cf6ce279c7671a4c83c960c5c526f92679a4fac8 (patch) | |
| tree | ed3a8e83efe38ad7a7969caba5376e2d6567007c /django/forms | |
| parent | fbc618c13cc72b9c2f4c8dfd5ef8b8ab5a5d7caa (diff) | |
| download | django-cf6ce279c7671a4c83c960c5c526f92679a4fac8.tar.gz | |
Fixed #24948 -- Fixed crash when uploading bitmap images in forms.ImageField
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 57d6a755c6..e2d573a56f 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -683,7 +683,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( |
