Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#12229 closed (fixed)

ImageField.save should be documented upfront and obvious

Reported by: freyley Owned by: Gabriel Hurley
Component: Documentation Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by Ramiro Morales)

Nowhere on this page

http://docs.djangoproject.com/en/dev/ref/models/fields/

Does it say how to save an image to a filefield or imagefield. Only by digging in to the code was I able to find this:

p = Photo(...)
p.image.save(filename, ContentFile(data))

which was exactly what I wanted. If there's a preferred way to do it, that'd be fine too.

Attachments (1)

12229_filefield_docs_patch.diff (3.9 KB) - added by Gabriel Hurley 7 years ago.
Updated patch for FileField/ImageField docs that include FieldFile information

Download all attachments as: .zip

Change History (10)

comment:1 Changed 7 years ago by Ramiro Morales

Description: modified (diff)

(formatted description)

comment:2 Changed 7 years ago by Russell Keith-Magee

milestone: 1.2
Triage Stage: UnreviewedAccepted

comment:3 Changed 7 years ago by Gabriel Hurley

Has patch: set
Owner: changed from nobody to Gabriel Hurley
Status: newassigned

Added a patch that adds a large chunk to the FileField docs regarding the publicly available methods that get added by the complex machinations of FieldFile. Updates the ImageField docs as well to make it a little more obvious that it gets everything from FileField.

comment:4 Changed 7 years ago by Russell Keith-Magee

Triage Stage: AcceptedReady for checkin

comment:5 Changed 7 years ago by Russell Keith-Magee

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

The content of this patch is all good stuff, but the patch still needs work.

In particular, it is missing two things:

  • A transition between the discussion about FileField, and the methods that are on FieldFile
  • Corrections to the markup that suggest that open() et al are methods on FileField -- they're on FieldFile.

Changed 7 years ago by Gabriel Hurley

Updated patch for FileField/ImageField docs that include FieldFile information

comment:6 Changed 7 years ago by Gabriel Hurley

Patch needs improvement: unset

Hopefully this addresses Russ' concerns above. It's a little tricky because even though the open, save, delete, etc. methods are in actuality on FieldFile, they are exposed on the FileField/ImageField instance itself. I tried to make this clear while still being technically accurate and adding a better logical separation.

comment:7 Changed 7 years ago by Russell Keith-Magee

Resolution: fixed
Status: assignedclosed

(In [13202]) Fixed #12229 -- Added documentation of the FieldFile methods that are exposed by FileField and ImageField. Thanks to Gabriel Hurley for the draft patch.

comment:8 Changed 7 years ago by Russell Keith-Magee

(In [13203]) [1.1.X] Fixed #12229 -- Added documentation of the FieldFile methods that are exposed by FileField and ImageField. Thanks to Gabriel Hurley for the draft patch.

Backport of r13202 from trunk.

comment:9 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

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