summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRiccardo Magliocchetti <riccardo.magliocchetti@gmail.com>2017-05-06 19:14:15 +0200
committerTim Graham <timograham@gmail.com>2017-05-11 19:39:42 -0400
commit643413f654d52ca4d7bf6d9402ff9ca24d2ea635 (patch)
treeac5b2a90b052002bd8c28f3d0f1dbfe524649874 /docs
parentcf81add99745f230f858652b7546da779fc39cd2 (diff)
[1.11.x] Fixed #28148 -- Doc'd ImageField name validation concerns with the test client.
Backport of bdf192c59357a0d8117f6f34c94fb32a51e7a774 from master
Diffstat (limited to 'docs')
-rw-r--r--docs/releases/1.11.txt6
-rw-r--r--docs/topics/testing/tools.txt10
2 files changed, 15 insertions, 1 deletions
diff --git a/docs/releases/1.11.txt b/docs/releases/1.11.txt
index 03a0a28dea..e43d53fdf8 100644
--- a/docs/releases/1.11.txt
+++ b/docs/releases/1.11.txt
@@ -742,6 +742,12 @@ Miscellaneous
* The signature of private API ``Widget.build_attrs()`` changed from
``extra_attrs=None, **kwargs`` to ``base_attrs, extra_attrs=None``.
+* File-like objects (e.g., :class:`~io.StringIO` and :class:`~io.BytesIO`)
+ uploaded to an :class:`~django.db.models.ImageField` using the test client
+ now require a ``name`` attribute with a value that passes the
+ :data:`~django.core.validators.validate_image_file_extension` validator.
+ See the note in :meth:`.Client.post`.
+
.. _deprecated-features-1.11:
Features deprecated in 1.11
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt
index 9b2e76cadc..1a2e9a847a 100644
--- a/docs/topics/testing/tools.txt
+++ b/docs/topics/testing/tools.txt
@@ -235,7 +235,15 @@ Use the ``django.test.Client`` class to make requests.
file-processing code expects.)
You may also provide any file-like object (e.g., :class:`~io.StringIO` or
- :class:`~io.BytesIO`) as a file handle.
+ :class:`~io.BytesIO`) as a file handle. If you're uploading to an
+ :class:`~django.db.models.ImageField`, the object needs a ``name``
+ attribute that passes the
+ :data:`~django.core.validators.validate_image_file_extension` validator.
+ For example::
+
+ >>> from io import BytesIO
+ >>> img = BytesIO(b'mybinarydata')
+ >>> img.name = 'myimage.jpg'
Note that if you wish to use the same file handle for multiple
``post()`` calls then you will need to manually reset the file