mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #11739 -- Made ContentFile support Unicode input
This commit is contained in:
parent
ebc773ada3
commit
361d6738f8
3 changed files with 25 additions and 9 deletions
|
@ -91,14 +91,18 @@ The ``ContentFile`` Class
|
|||
.. class:: ContentFile(File)
|
||||
|
||||
The ``ContentFile`` class inherits from :class:`~django.core.files.File`,
|
||||
but unlike :class:`~django.core.files.File` it operates on string content,
|
||||
rather than an actual file. For example::
|
||||
but unlike :class:`~django.core.files.File` it operates on string content
|
||||
(bytes also supported), rather than an actual file. For example::
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from django.core.files.base import ContentFile
|
||||
|
||||
f1 = ContentFile(b"my string content")
|
||||
f2 = ContentFile("my unicode content encoded as UTF-8".encode('UTF-8'))
|
||||
f1 = ContentFile("esta sentencia está en español")
|
||||
f2 = ContentFile(b"these are bytes")
|
||||
|
||||
.. versionchanged:: 1.5
|
||||
|
||||
ContentFile also accepts Unicode strings.
|
||||
|
||||
.. currentmodule:: django.core.files.images
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue