Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#12589 closed (invalid)

upload_to argument on FileField It is not completely clear in the documentation

Reported by: finngruwier Owned by: nobody
Component: Documentation Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


The documentation says: "A local filesystem path that will be appended to your MEDIA_ROOT setting...". However, if file_field is a callable, the value returned from the callable will be used as the full path for the file, thus ignoring the MEDIA_ROOT setting.

Change History (2)

comment:1 Changed 8 years ago by Karen Tracey

Resolution: invalid
Status: newclosed

The MEDIA_ROOT setting is not ignored if the upload_to is a callable. The callable upload_to is expected to return a local filesystem path that will then be appended to MEDIA_ROOT, just like a static upload_to. (Note in both cases if these values turn out to be absolute paths then that absolute path will be used. This will usually result in a SuspiciousOperation exception since Django won't allow writing to files outside the MEDIA_ROOT tree. If, however, the absolute path happens to fall inside the MEDIA_ROOT tree then things will work.)

comment:2 Changed 8 years ago by finngruwier

Ah - I see.

Thanks for pointing this out.

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