Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#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)

file_objects.diff (1.4 KB ) - added by Ethan Jucovy 14 years ago.
file_objects.2.diff (1.4 KB ) - added by Ethan Jucovy 14 years ago.

Download all attachments as: .zip

Change History (9)

by Ethan Jucovy, 14 years ago

Attachment: file_objects.diff added

comment:1 by Ethan Jucovy, 14 years ago

Cc: ethan.jucovy@… added

comment:2 by Aymeric Augustin, 14 years ago

Triage Stage: UnreviewedAccepted

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.

comment:3 by patchhammer, 14 years ago

Patch needs improvement: set

file_objects.diff fails to apply cleanly on to trunk

by Ethan Jucovy, 14 years ago

Attachment: file_objects.2.diff added

comment:4 by Ethan Jucovy, 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 dmclain, 14 years ago

Triage Stage: AcceptedReady for checkin

comment:6 by Chris Beaven, 14 years ago

Resolution: fixed
Status: newclosed

In [16207]:

Fixes #15963 -- Misleading FileField.save documentation. Thanks for the report and patch, ejucovy.

comment:7 by Chris Beaven, 14 years ago

In [16208]:

[1.3.X] Fixes #15963 -- Misleading FileField.save documentation. Thanks for the report and patch, ejucovy.

Backport of r16207 from trunk.

Note: See TracTickets for help on using tickets.
Back to Top