Ticket #14762: document-contentfile.diff

File document-contentfile.diff, 1.2 KB (added by Adam Vandenberg, 13 years ago)

Documents "ContentFile" and fixes a typo on "ImageFile".

  • docs/ref/files/file.txt

    diff --git a/docs/ref/files/file.txt b/docs/ref/files/file.txt
    index 146ab4d..ae14434 100644
    a b methods:  
    8181
    8282.. currentmodule:: django.core.files.images
    8383
    84 Additional ``ImageField`` attributes
     84Additional ``ImageFile`` attributes
    8585------------------------------------
    8686
    8787.. class:: ImageFile(file_object)
    above) will also have a couple of extra methods:  
    117117        >>> car.photo.save('myphoto.jpg', contents, save=True)
    118118   
    119119    Note that the ``content`` argument must be an instance of
    120     :class:`File` or of a subclass of :class:`File`.
     120    :class:`File` or of a subclass of :class:`File` such as :class:`ContentFile`.
    121121
    122122.. method:: File.delete([save=True])
    123123
    124124    Remove the file from the model instance and delete the underlying file. The
    125125    ``save`` argument works as above.
     126
     127``ContentFile`` objects
     128-----------------------
     129
     130.. class:: ContentFile(File)
     131
     132A ``ContentFile`` is a File-like object that takes string content, rather
     133than an actual file::
     134
     135    from django.core.files import ContentFile
     136
     137    f1 = ContentFile("my string content")
     138    f2 = ContentFile(u"my unicode content encoded as UTF-8".encode('UTF-8'))
Back to Top