Ticket #8641: 8641.file-doc.diff

File 8641.file-doc.diff, 1.3 KB (added by julien, 7 years ago)

Fixed doc bug, and added clarification about the expected format for saving files

  • django/django/docs/topics/files.txt

    9696useful -- you can use the global default storage system::
    9898    >>> from django.core.files.storage import default_storage
     99    >>> from django.core.files.base import ContentFile
    100     >>> path = default_storage.save('/path/to/file', 'new content')
     101    >>> path = default_storage.save('/path/to/file', ContentFile('new content'))
    101102    >>> path
    102103    u'/path/to/file'
  • django/django/docs/ref/files/storage.txt

    4141If there already exists a file with this name ``name``, the storage system may
    4242modify the filename as necessary to get a unique name. The actual name of the
    4343stored file will be returned.
     44Also, the given ``content`` has to be a :ref:`Django File <ref-files-file>`
     45object. If you need to save another type of object -- a string for example --
     46you'll need to first wrap it into a Django File object.
Back to Top