#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 | 
Description
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.
Usage:
icon = models.FilePathField(path="/Users/scum/Sites/testsite/templates/media/img/icons/", match=".+.[gif|jpg]", recursive=True, web_path="/images/icons")
Examples:
/Users/scum/Sites/testsite/templates/media/images/icons/icon1.gif
will be saved as '/img/icons/icon1.gif' in the database
/Users/scum/Sites/testsite/templates/media/images/icons/directoryName/icon2.gif
will be saved as '/img/icons/directoryName/icon2.gif' in the database
Attachments (1)
Change History (3)
by , 19 years ago
| Attachment: | FilePathFieldEnhancement.diff added | 
|---|
comment:1 by , 19 years ago
| Resolution: | → wontfix | 
|---|---|
| Status: | new → closed | 
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 by , 19 years ago
Sorry, that resolution decision was made by me. Was accidently not logged in.
[patch] FilePathField web_path enhancement