Code

Opened 4 years ago

Closed 4 years ago

Last modified 4 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:

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.

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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 4 years ago by finngruwier

Ah - I see.

Thanks for pointing this out.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.