name = models.FileField(upload_to=get_absolute_url, max_length=255)
upload_to usually looks like this
upload_to ='./files'
It will be stored as ./files/your.file in the db
and as <MEDIA_ROOT>/files/your.file
at your disk
You can change the upload_to
-String to whatever fits best for you programatically
upload_to ='./files'+'/subdir'
but it should start with './'
get_absolute_url()
should return a url like http://domain.com/sitemedia/files/your.file
EDIT:
to remove the path from the file name you could do string operations in File.save() like
def save(self, force_insert=False, force_update=False):
self.name = self.name[self.name.rfind('/')+1:]
super(File, self).save(force_insert, force_update)
vikingosegundo
2009-05-28 15:20:45