Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#18840 closed Cleanup/optimization (fixed)

Important upload_to parameter is missing from upload doc

Reported by: Tuttle Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The file uploads topic and even ref page don't mention the upload_to parameter that is required:

If the newbie follows the top example on the topic page:

class UploadFileForm(forms.Form):
    title = forms.CharField(max_length=50)
    file  = forms.FileField()

he or she is immediatelly confused by the model validation error.

Change History (4)

comment:1 Changed 4 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Bug to Cleanup/optimization

It would be out-of-place and confusing to say anything about upload_to near where the quoted snippet appears in the documentation, because that snippet concerns a plain form, not a model form, and putting upload_to on the forms.FileField would be an error. upload_to is a required parameter of models.FileField, and its documentation clearly notes that ( Where upload_to could be mentioned in the referenced doc is: Something could be added in those first two sentences noting that the models.FileField upload_to parameter controls where the file will be saved.

I don't think it would be appropriate to add any mention of upload_to to the forms field reference, as it is not a parameter of the forms-level FileField.

comment:2 Changed 4 years ago by Tuttle

Of course, I confused the forms vs. models FileField myself. :) Sorry for the noise.

Last edited 4 years ago by Tuttle (previous) (diff)

comment:3 Changed 4 years ago by Tim Graham <timograham@…>

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

In [c6088bc91d29b6b49eba0ec82b0239a557c658ef]:

Fixed #18840 - Added a mentioned of the upload_to parameter to the ModelForm example in file uploads.

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

In [c9f1a13f87174b21fe2b6230fc1b2f44e03c8d61]:

[1.4.X] Fixed #18840 - Added a mentioned of the upload_to parameter to the ModelForm example in file uploads.

Backport of c6088bc91d from master

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