mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
[1.11.x] Fixed #28148 -- Doc'd ImageField name validation concerns with the test client.
Backport of bdf192c593 from master
This commit is contained in:
committed by
Tim Graham
parent
cf81add997
commit
643413f654
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user