Loading docs/ref/files/file.txt +21 −8 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ methods: .. currentmodule:: django.core.files.images Additional ``ImageField`` attributes Additional ``ImageFile`` attributes ------------------------------------ .. class:: ImageFile(file_object) Loading Loading @@ -117,9 +117,22 @@ above) will also have a couple of extra methods: >>> 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')) Loading
docs/ref/files/file.txt +21 −8 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ methods: .. currentmodule:: django.core.files.images Additional ``ImageField`` attributes Additional ``ImageFile`` attributes ------------------------------------ .. class:: ImageFile(file_object) Loading Loading @@ -117,9 +117,22 @@ above) will also have a couple of extra methods: >>> 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'))