Filebrowser uses absolute instead of relative path

25 views
Skip to first unread message

Robrecht Colson

unread,
Feb 19, 2015, 6:53:05 AM2/19/15
to djangofi...@googlegroups.com
Hey guys! I'm kind of new to Django. I'm looking into filebrowser for some front-end file management. I've got it installed and somewhat properly configured - when I'm in my admin panel, I can see the files in my /media/images folder. However, when I try accessing these files, the URL is localhost:8000/home/robbie/desktop/folder/project/media/images/file.jpg. I'm sure there is an easy fix for this, but I've played with my settings.py a bit and I couldn't find it. Here's the relevant part of my settings: 

BASE_DIR = os.path.dirname(os.path.dirname(__file__))
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media/')
MEDIA_URL = '/media/'

FILEBROWSER_MEDIA_ROOT = MEDIA_ROOT
FILEBROWSER_DIRECTORY = MEDIA_URL


Does anyone know how to fix this? Many thanks in advance! 

Robrecht Colson

unread,
Feb 19, 2015, 7:09:06 AM2/19/15
to djangofi...@googlegroups.com
The above settings are actually incorrect. This 

BASE_DIR = os.path.dirname(os.path.dirname(__file__))
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
MEDIA_URL = '/media/'
FILEBROWSER_MEDIA_ROOT = MEDIA_ROOT
FILEBROWSER_DIRECTORY = MEDIA_ROOT

is what I'm actually using

Derek Adair

unread,
Mar 15, 2016, 7:54:24 PM3/15/16
to Django FileBrowser
Try removing all of the FILEBROWSER_ settings and using these configs for your static/media

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, STATIC_URL.strip("/"))
MEDIA_URL = STATIC_URL + "media/"
MEDIA_ROOT = os.path.join(PROJECT_ROOT, *MEDIA_URL.strip("/").split("/"))
Reply all
Reply to author
Forward
0 new messages