I'm using wysiwyg redactor for admin page. So I can add some images to my articles. Firstly, In settings.pyI wrote:
REDACTOR_UPLOAD = '/media/uploads/'
MEDIA_ROOT = '/media/'
MEDIA_URL = '/media/'
in this case, all uploaded images are in C:\media\uploads. It's working.
But I need images to be located in project folder. So I write:
REDACTOR_UPLOAD = os.path.abspath('/media/uploads/')
MEDIA_ROOT = os.path.abspath('media')
MEDIA_URL = '/media/'
Then image location: src="/media/C%3A/virtenvs/web/src/mysite/media/uploads/CAM00415.jpg"
But when debugging settings.py, MEDIA_ROOT = 'C:\\virtenvs\\web\\src\\mysite\\media'
Why?
You put a relative path in
MEDIA_ROOTand an absolute path inREDACTOR_UPLOAD. Compare the following two in an interactive console:C:\Users\<username>is the current working directory here. Unless you use an absolute path (starting with a/), the path inabspathwill get appended to your current directory. The working directory of django seems to beC:\virtenvs\web\src\mysite, which also appears to be your project's directory, so in this case using a relative path for both settings should work: