Opened 21 months ago

Last modified 21 months ago

#34237 closed Bug

FileField does not take upload_to into account when setting unique=True — at Version 1

Reported by: 0x4A-0x41-0x4B Owned by: nobody
Component: File uploads/storage Version: 4.1
Severity: Normal Keywords: FileField, Unique, Storage, Upload
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by 0x4A-0x41-0x4B)

#27188 added support for setting unique=True to the FileField.
This does not seem to take the upload_to argument into account.

As upload_to could be used to completely change the name of the uploaded file it should, in my opinion, be considered part of the filename.
Or should at the very least be mentioned in the docs for clarity.

If upload_to is defined, setting unique=True does effectively nothing right now. The file is passed on and a unique filename is generated (->The default behavior of adding an underscore followed by seven random characters) instead of raising an error.

Change History (1)

comment:1 by 0x4A-0x41-0x4B, 21 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top