Fixed #11739 -- Made ContentFile support Unicode input

This commit is contained in:
Claude Paroz 2012-08-29 09:45:02 +02:00
parent ebc773ada3
commit 361d6738f8
3 changed files with 25 additions and 9 deletions

View file

@ -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