From 8b7347220f3d86b46f5f87270c6cdcb9960895fd Mon Sep 17 00:00:00 2001 From: Petras Zdanavičius Date: Sat, 26 Jul 2014 15:25:44 +0300 Subject: Fixed #23103 -- Annotated ImageField file with image and content_type attributes. Thanks Jeremy Dunck for the suggestion and Nick Sanford for review. --- docs/ref/forms/fields.txt | 9 +++++++++ docs/releases/1.8.txt | 6 ++++++ 2 files changed, 15 insertions(+) (limited to 'docs') diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt index a886536597..e92013a832 100644 --- a/docs/ref/forms/fields.txt +++ b/docs/ref/forms/fields.txt @@ -649,7 +649,16 @@ For each field, we describe the default widget used if you don't specify When you use an ``ImageField`` on a form, you must also remember to :ref:`bind the file data to the form `. + .. versionchanged:: 1.8 + + After the field has been cleaned and validated, the ``UploadedFile`` + object will have an additional ``image`` attribute containing the Pillow + `Image`_ instance used to check if the file was a valid image. + ``UploadedFile.content_type`` is also updated with the image's content + type as determined by Pillow. + .. _Pillow: http://pillow.readthedocs.org/en/latest/ +.. _Image: https://pillow.readthedocs.org/en/latest/reference/Image.html ``IntegerField`` ~~~~~~~~~~~~~~~~ diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt index d4943fd0da..15dca75e1d 100644 --- a/docs/releases/1.8.txt +++ b/docs/releases/1.8.txt @@ -160,6 +160,12 @@ Forms :attr:`~django.forms.extras.widgets.SelectDateWidget.empty_label` argument, which will override the top list choice label when :class:`~django.forms.DateField` is not required. +* After an :class:`~django.forms.ImageField` has been cleaned and validated, the + ``UploadedFile`` object will have an additional ``image`` attribute containing + the Pillow ``Image`` instance used to check if the file was a valid image. It + will also update ``UploadedFile.content_type`` with the image's content type + as determined by Pillow. + Internationalization ^^^^^^^^^^^^^^^^^^^^ -- cgit v1.3