I'm using Django's Admin site to manage some data - but not building a webapp. I need the file upload field to store only the file name in the database.
Right now I can get absolute paths like: /Users/me/uploads/file.png
Or using the upload_to parameter get something like this in the database: uploads/file.png
How can I get it to be this: file.png
EDIT:
I'm taking the sqlite database and using in another client - so having any paths in the db entry doesn't make sense in my case.
Thanks!
os.path.basename
is what you're looking for, but luc's answer here really encapsulates it in a very django/pythonesque way. – Custard