#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: | no | UI/UX: | no |
Description
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.
Note:
See TracTickets
for help on using tickets.
The MEDIA_ROOT setting is not ignored if the
upload_to
is a callable. The callableupload_to
is expected to return a local filesystem path that will then be appended to MEDIA_ROOT, just like a staticupload_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.)