#3538 closed (wontfix)
[Patch] Add get_FOO_basename() for FileFields
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Keywords: | filefield basename filename | |
Cc: | herbert.poul@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
It is currently only possible to retrieve absolute pathname or URL of an uploaded file, but not it's basename..(ie. bare filename without any path) - imho this is a very common need.. and i checked dozend of times before believing that it's not already there (i hope i didn't miss it though ;) )
this patch adds a get_FOO_basename() which looks exactly like the existing get_FOO_url() and get_FOO_filename() methods .. and returns only the bare filename.
Attachments (1)
Change History (5)
by , 18 years ago
Attachment: | filefield_basename_trunk.diff added |
---|
comment:2 by , 18 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
This is just sugar for os.path.basename(obj.get_FOO_filename())
, and so it's a bit too feature-creepy for me. Just use os.path
(or, better yet, a path module like Unipath).
comment:3 by , 18 years ago
imho... if you have a model with a fileupload .. it makes most sense to display the filename in a template..
you will never need the full path or path relative to MEDIA_ROOT ..
so .. i think basename is more useful than the current 'filename' .. because if i ever need 'filename' it's in a view where i can use python code like os.path .. while in a template where i want to output a file's name i need the basename..
of course.. i could simply write a custom method for my model or a template filter.. but i think outputting the name of an uploaded file is somewhat the basic functionality for a fileupload ?
it would be nice if you could rethink this.. it's just 2 lines of code.. but anyway .. maybe i'm missing some important point here.. so i leave the ticket closed ..
simple patch for latest svn trunk