Code

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#2598 closed enhancement (wontfix)

[patch] Added web_path option to FilePathField

Reported by: scum Owned by: adrian
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: UI/UX:

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)

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

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by scum

[patch] FilePathField web_path enhancement

comment:1 Changed 8 years ago by anonymous

  • Resolution set to wontfix
  • Status changed from new to 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 Changed 8 years ago by mtredinnick

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.