Misleading FileField.save documentation, no reference to django.core.files.File
The documentation for FileField.save
(http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FieldFile.save) claims:
Takes two required arguments: name which is the name of the file, and content which is a file-like object containing the file's contents.
This is incorrect; content
is *not* a "file-like object" -- it's a django.core.files.File
-like object.
Attempting to do field.save(name, open(my_file))
results in an AttributeError: 'file' object has no attribute 'chunks'
. The correct spelling is instead field.save(name, django.core.files.File(open(my_file)))
.
I've attached a patch to the docs which makes this clear, and also refers the reader to the documentation about Django File objects.
Triage Stage: |
Unreviewed → Accepted
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
These other tickets are related to FileField's documentation, but they don't describe this specific problem: #9535 (very broad), #15588 (already RFC), and #15646.