Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#18840 closed Cleanup/optimization (fixed)

Important upload_to parameter is missing from upload doc

Reported by: Vlada Macek 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

Description

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 by Karen Tracey, 12 years ago

Triage Stage: UnreviewedAccepted
Type: BugCleanup/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 (https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField). Where upload_to could be mentioned in the referenced doc is: https://docs.djangoproject.com/en/dev/topics/http/file-uploads/#handling-uploaded-files-with-a-model. 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 by Vlada Macek, 12 years ago

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

Version 0, edited 12 years ago by Vlada Macek (next)

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

Resolution: fixed
Status: newclosed

In [c6088bc91d29b6b49eba0ec82b0239a557c658ef]:

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

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

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