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
-
My new favorite Slanket quote "it leaves plenty of room for you to fat-up into it" http://snurl.com/31i1j@alexgraves just came home with 2 bikes she got at a yard sale for $15. Total bikes in our living room is now 5.- Photo: http://bkite.com/00YE5@brosner congrats on the merge, I know what I'll be doing this weekend.- Photo: http://bkite.com/00YBl
