Django server side file selector
Published Wed Sep 28th 2005 in Django PythonNote: This is no longer valid. You can now use the meta.FilePathField that is built into Django like this
fieldName = meta.FilePathField(path='/path/to/files', match='re_string', recursive=True)
videoUrl = meta.ServerFileField('/home/user/video')
from django.core import meta
import os
videoDir = '/home/jay/video'
files = os.listdir(videoDir)
theList = []
for f in files:
if os.path.isfile(os.path.join(videoDir,f)):
theList.append(tuple([os.path.join(videoDir,f), f]))
videoChoices = tuple(theList)
class Message(meta.Model):
def __repr__(self):
return self.name
title = meta.CharField(maxlength=200)
video = meta.CharField(maxlength=200, help_text='Select the video', choices=videoChoices ,blank=True)
...
Latest
Xbox Live Gamercard
-
Retweeting @Squeat: Hug a developer! ยป http://svvarm.com/raI just saw a Woodleys.com ad on TV and thought, "huh, I built that" well @twentystar helped ;)Riot police - Photo: http://bkite.com/01onH

Riot police
Jackass on a segway