Skip to content

Instantly share code, notes, and snippets.

@sehmaschine
Created April 25, 2012 16:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sehmaschine/2491298 to your computer and use it in GitHub Desktop.
Save sehmaschine/2491298 to your computer and use it in GitHub Desktop.
Multiple FileBrowser Sites
from filebrowser.sites import site
from django.core.files.storage import DefaultStorage, default_storage, FileSystemStorage
site_1 = site(name="First FB Site", app_name="filebrowser", storage=default_storage) # default filebrowser site
site_2 = site(name="Second FB Site", app_name="filebrowser", storage=FileSystemStorage)
@robrocker7
Copy link

I am trying to use the following code and getting a TypeError : 'FileBrowserSite' object is not callable. I am wanting to just override the default directory so when the user goes to upload a file the directory changes based upon on object that is changed in a process_request() middleware.

    filepath = os.path.join(settings.MEDIA_ROOT, 'uploads', 'obj_%s' % obj.id)

    storage = DefaultStorage()
    storage.location = filepath
    storage.base_url = '/media/'
    site(name="%s site" % obj.name, storage=storage, app_name="filebrowser")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment