views:

185

answers:

1

Hi, I've set django filebrowser's debug to True and wrote the extension restrictions in the model.

pdf = FileBrowseField("PDF", max_length=200, directory="documents/", extensions=['.pdf', '.doc', '.txt'], format='Document', blank=True, null=True)

In django admin it shows correctly with debug info. Directory documents/ Extensions ['.pdf', '.doc', '.txt'] Format Document

But when I call the filebrowser, it allows all file extensions to be uploaded.

How can I restrict filebrowser to upload only certain filetypes that I want?

Thanks everyone

A: 

In filebrowser/fb_seettings define them as a dictionary called EXTENSIONS.

EXTENSIONS = {
    'Folder':[''],
    'Image':['.jpg', '.jpeg', '.gif','.png','.tif','.tiff'],
    'Zip':['.zip', '.rar'],
    'Video':['.mov','.wmv','.mpeg','.mpg','.avi','.rm'],
    'Document':['.pdf','.doc','.rtf','.txt','.xls','.csv'],
    'Sound':['.mp3','.mp4','.wav','.aiff','.midi'],
    'Code':['.html','.py','.js','.css']
}

Edit: If you want if in your FileBrowserField:

pdf = FileBrowseField("PDF", max_length=200, initial_directory="documents/", extensions_allowed={'Documents':['.pdf', '.doc', '.txt']}, format="Documents", blank=True, null=True)
Alcides
I already have that defined by default in the settings.py file.The problem is overriding the default settings with those defined in the model filebrowsefield arguments.
Borislav
Can you please tell which version of filebrowser you're using, and where you found it?My version, which i checked out from svn trunk doesn't have extensions_allowed or initial_directory as variables.Just extensions and directory.
Borislav