Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#12229 closed (fixed)

ImageField.save should be documented upfront and obvious

Reported by: freyley Owned by: gabrielhurley
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)

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 gabrielhurley 4 years ago.
Updated patch for FileField/ImageField docs that include FieldFile information

Download all attachments as: .zip

Change History (10)

comment:1 Changed 4 years ago by ramiro

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

(formatted description)

comment:2 Changed 4 years ago by russellm

  • milestone set to 1.2
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 4 years ago by gabrielhurley

  • Has patch set
  • Owner changed from nobody to gabrielhurley
  • Status changed from new to assigned

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 4 years ago by russellm

  • Triage Stage changed from Accepted to Ready for checkin

comment:5 Changed 4 years ago by russellm

  • Patch needs improvement set
  • Triage Stage changed from Ready for checkin to Accepted

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 4 years ago by gabrielhurley

Updated patch for FileField/ImageField docs that include FieldFile information

comment:6 Changed 4 years ago by gabrielhurley

  • 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 4 years ago by russellm

  • Resolution set to fixed
  • Status changed from assigned to closed

(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 4 years ago by russellm

(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 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.