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 Alive! http://yfrog.com/0l99834563j
Add to your Queue!
Fear and Loathing in Las Vegas
Add to your Queue!
Best in Show
I got my 4th of July Rockies hat today. I still have to bend it. I'm not a flat brim kind of guy. http://hangr.me/wbzlq/
Add to your Queue!
Operation Valkyrie: The Stauffenberg Plot to Kill Hitler
@casciato I am in love with http://www.inevitablezombieapocalypse.com/ In the past week I have watched Zombie Wars and American Zombie.
