#15963 closed Cleanup/optimization (fixed)
Misleading FileField.save documentation, no reference to django.core.files.File
Reported by: | Ethan Jucovy | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | ethan.jucovy@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
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.
Attachments (2)
Change History (9)
by , 14 years ago
Attachment: | file_objects.diff added |
---|
comment:1 by , 14 years ago
Cc: | added |
---|
comment:2 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 14 years ago
Patch needs improvement: | set |
---|
file_objects.diff fails to apply cleanly on to trunk
by , 14 years ago
Attachment: | file_objects.2.diff added |
---|
comment:4 by , 14 years ago
Patch needs improvement: | unset |
---|
Original patch was generated from within the docs/
directory. New patch file_objects.2.diff should apply cleanly from the root of the checkout.
comment:5 by , 14 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
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.