Author: timo
Date: 2010-11-28 14:14:40 -0600 (Sun, 28 Nov 2010)
New Revision: 14743

Modified:
   django/branches/releases/1.2.X/docs/ref/files/file.txt
Log:
[1.2.X] Fixed #14762 - Add documention for ContentFile. Thanks jesh for the 
suggestion and adamv for the patch.

Backport of r14742 from trunk.

Modified: django/branches/releases/1.2.X/docs/ref/files/file.txt
===================================================================
--- django/branches/releases/1.2.X/docs/ref/files/file.txt      2010-11-28 
20:14:04 UTC (rev 14742)
+++ django/branches/releases/1.2.X/docs/ref/files/file.txt      2010-11-28 
20:14:40 UTC (rev 14743)
@@ -29,7 +29,7 @@
         The URL where the file can be retrieved. This is often useful in
         :doc:`templates </topics/templates>`; for example, a bit of a template 
for
         displaying a ``Car`` (see above) might look like:
-        
+
         .. code-block:: html+django
 
             <img src='{{ car.photo.url }}' alt='{{ car.name }}' />
@@ -81,13 +81,13 @@
 
 .. currentmodule:: django.core.files.images
 
-Additional ``ImageField`` attributes
+Additional ``ImageFile`` attributes
 ------------------------------------
 
 .. class:: ImageFile(file_object)
 
     .. attribute:: width
-        
+
         Width of the image.
 
     .. attribute:: height
@@ -108,18 +108,31 @@
     replace the existing file, but will create a new file and update the object
     to point to it. If ``save`` is ``True``, the model's ``save()`` method will
     be called once the file is saved. That is, these two lines::
-    
+
         >>> car.photo.save('myphoto.jpg', contents, save=False)
         >>> car.save()
-    
+
     are the same as this one line::
-    
+
         >>> car.photo.save('myphoto.jpg', contents, save=True)
-    
+
     Note that the ``content`` argument must be an instance of
-    :class:`File` or of a subclass of :class:`File`.
+    :class:`File` or of a subclass of :class:`File` such as 
:class:`ContentFile`.
 
 .. method:: File.delete([save=True])
 
     Remove the file from the model instance and delete the underlying file. The
     ``save`` argument works as above.
+
+``ContentFile`` objects
+-----------------------
+
+.. class:: ContentFile(File)
+
+A ``ContentFile`` is a File-like object that takes string content, rather
+than an actual file::
+
+    from django.core.files.base import ContentFile
+
+    f1 = ContentFile("my string content")
+    f2 = ContentFile(u"my unicode content encoded as UTF-8".encode('UTF-8'))

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to