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
-
It's been a great week at @doubleencore. A lot of progress on a lot of apps.I love the new @Twitter app for iPad, but the lack of @instapaper support really hurts.That tweet by @BigCatJared was perfectly timed. http://tweetphoto.com/42866422I have lost 4 @foursquare mayorships in the last 2 days. It's a blood bath.I got some new Blik for my office wall. http://yfrog.com/2ooduvj
