Django FileBrowser 400 Error

2019-08-09 11:58发布

问题:

I'm getting a 400 error when trying to access the /admin/filebrowser/browse/ page. I followed the instructions as per https://django-filebrowser.readthedocs.org/en/3.5.2/quickstart.html and have my URLs and installed apps configured correctly.

What I'm not too sure about are the media paths in settings.py;

FILEBROWSER_DIRECTORY = os.path.join(BASE_DIR, '/ogencat/MEDIA/uploads')

FILEBROWSER_MEDIA_ROOT = os.path.join(BASE_DIR, '/ogencat/MEDIA')

FILEBROWSER_MEDIA_URL = '/MEDIA/'

I have folder in my workspace called MEDIA and a folder within called uploads.

I wasn't too sure about what the docs wanted me to do in terms of setting these paths - I hadn't seen the getattr(settings, "FILEBROWSER_MEDIA_ROOT", settings.MEDIA_ROOT) syntax before so I just added the paths as I have done for the rest of settings.py

Thanks!

回答1:

  1. You need to add trailing slashes
  2. Directories must exist prior accessing them