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
-
RT @doubleencore: Here's the brand new Double Encore Download -- the latest inside the company, our #apps, and more http://t.co/hqDB2zNa #iOSRSVP for the Push IO WWDC 2012 Party http://t.co/uUpA0BNU via @prismaticI just earned the 'American Craft Beer Week (2012)' badge on @untappd! http://t.co/Vted9Kye #acbwRT @onyx: Ever had an issue rendering a dashed line in #ICS? It seems to be a bug: http://t.co/jASqPTTf See my comment for a work-around. #AndroidDevSo the soda stream CO2 canister that came with my soda maker is not owned by me. Only provided a license. Weird http://t.co/WEyN1GsmThe @doubleencore hitting cage is open for business. http://t.co/az5teEwZ. @djbriane @jeremyvinding I think Diablo 3 Guest Pass only comes in the box version. If anyone bought that I'ld love the Guest Pass :)RT @devinreams: Check out these cool #Colorado state flag HTML t-shirts @crowdfavorite is selling: http://t.co/GvcoUrEp http://t.co/u1qR8llZDoes anyone want a @Prismatic invite?RT @glassboard: Allow me to introduce you all to Glassboard 2.0. http://t.co/br6fjvZ0 You'll be amazed with what we've done.
