Code

Ticket #8641: 8641.file-doc.diff

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

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

Line 
1Index: django/django/docs/topics/files.txt
2===================================================================
3--- django/django/docs/topics/files.txt (revision 8696)
4+++ django/django/docs/topics/files.txt (working copy)
5@@ -96,8 +96,9 @@
6 useful -- you can use the global default storage system::
7 
8     >>> from django.core.files.storage import default_storage
9+    >>> from django.core.files.base import ContentFile
10 
11-    >>> path = default_storage.save('/path/to/file', 'new content')
12+    >>> path = default_storage.save('/path/to/file', ContentFile('new content'))
13     >>> path
14     u'/path/to/file'
15 
16Index: django/django/docs/ref/files/storage.txt
17===================================================================
18--- django/django/docs/ref/files/storage.txt    (revision 8696)
19+++ django/django/docs/ref/files/storage.txt    (working copy)
20@@ -41,6 +41,9 @@
21 If there already exists a file with this name ``name``, the storage system may
22 modify the filename as necessary to get a unique name. The actual name of the
23 stored file will be returned.
24+Also, the given ``content`` has to be a :ref:`Django File <ref-files-file>`
25+object. If you need to save another type of object -- a string for example --
26+you'll need to first wrap it into a Django File object.
27 
28 ``Storage.delete(name)``
29 ~~~~~~~~~~~~~~~~~~~~~~~~