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
-
Develop Denver @dvlpdnvr looks cool. http://t.co/hX3GVEUkSnow covered skylights give the @doubleencore office a weird glow this morning. (at @doubleencore) [pic] — http://t.co/YaUzBsOkToday @doubleencore I.. Shipped an app Setup our 5th build server Played a game Played with TV & Airplay Now hiring http://t.co/I9UPTNu3Terminal has an icon with white text on a dark bkgrnd. The default Terminal window is black text on a white bkgrnd Why? http://t.co/AyJDZZK7What ever happened to Burnout Crash for iOS. http://t.co/OjKCdJ8r Wasn't that supposed to be out last year?I spent some time today sitting at my desk playing video games. Because it's my job :)DESCENDENTS (at Fillmore Auditorium) — http://t.co/CMoFYGQ4I just earned the 'I Believe in IPA! (Level 2)' badge on @untappd from Hoptopia! http://t.co/2Xzkbhx2 #ibelieveinIPASuck it Carl! (with Nick at Yazoo BBQ Company) [pic] — http://t.co/Dk7qV8i9
