Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#2598 closed enhancement (wontfix)

[patch] Added web_path option to FilePathField

Reported by: scum Owned by: Adrian Holovaty
Component: contrib.admin Version:
Severity: normal Keywords: FilePathField
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I understand that you need the full path in order to scan the directory for files but saving the full path information to the database seems completely worthless. When I am using an object with a filepath field, I need access to the web relative path, not the file system relative path. What is needed is a web_path variable. This optional keyword will remove the regular path and replace it with the web_path.

icon = models.FilePathField(path="/Users/scum/Sites/testsite/templates/media/img/icons/", match=".+.[gif|jpg]", recursive=True, web_path="/images/icons")

will be saved as '/img/icons/icon1.gif' in the database

will be saved as '/img/icons/directoryName/icon2.gif' in the database

Attachments (1)

FilePathFieldEnhancement.diff (2.8 KB) - added by scum 13 years ago.
[patch] FilePathField web_path enhancement

Download all attachments as: .zip

Change History (3)

Changed 13 years ago by scum

[patch] FilePathField web_path enhancement

comment:1 Changed 13 years ago by anonymous

Resolution: wontfix
Status: newclosed

We don't want to jumble up filesystem paths and URLs -- which is what you are calling a web_path -- like that. FileField and its derivatives store the path to the file in the filesystem. Mapping that to a URL is done using methods like get_FOO_url().

comment:2 Changed 13 years ago by Malcolm Tredinnick

Sorry, that resolution decision was made by me. Was accidently not logged in.

Note: See TracTickets for help on using tickets.
Back to Top