Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#17016 closed New feature (fixed)

File uploading documentation leaves out the easiest method for saving a file with a model

Reported by: tim.saylor@… Owned by: nobody
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The only source I found for this method of saving a file from a form to a model was on stack overflow. It should be in the documentation so it's easier to find.

Attachments (2)

model_file_uploads.diff (1.8 KB ) - added by tim.saylor@… 13 years ago.
17016.diff (2.5 KB ) - added by Tim Graham 12 years ago.

Download all attachments as: .zip

Change History (7)

by tim.saylor@…, 13 years ago

Attachment: model_file_uploads.diff added

comment:1 by Aymeric Augustin, 13 years ago

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

The patch looks good overall, but I have a few suggestions:

  • We should mention ModelForms first, because they're really the easiest way to save files from a form into a model.
  • The key information of this paragraph is this line: ModelWithFileField(file_field=request.FILES['file']). However, you patch talks a lot about upload_to and that blurs a bit the message. upload_to is documented in the fields API under FileField; in my opinion it isn't necessary to duplicate the information here.
  • there's a small typo : reqeust.FILES
  • AUTHORS is sorted alphabetically by last name, first name.

by Tim Graham, 12 years ago

Attachment: 17016.diff added

comment:2 by Tim Graham, 12 years ago

Patch needs improvement: unset

comment:3 by Claude Paroz, 12 years ago

Little improvements I'd made:

  • Use render instead of render_to_response
  • Use explicit relative imports (from .forms, from .models)
  • UploadFileForm is not imported in the second example

comment:4 by Tim Graham <timograham@…>, 12 years ago

Resolution: fixed
Status: newclosed

In [eff6ba2f64ea5426502daadb04fbe1e85ace068a]:

Fixed #17016 - Added examples for file uploads in views.

Thanks Tim Saylor for the draft patch and Aymeric Augustin and Claude Paroz for feedback.

comment:5 by Tim Graham <timograham@…>, 12 years ago

In [fba0149e1604ad4ab3745abff8bba0d38bbfe321]:

[1.4.X] Fixed #17016 - Added examples for file uploads in views.

Thanks Tim Saylor for the draft patch and Aymeric Augustin and Claude Paroz for feedback.

Backport of eff6ba2f64 from master

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