Straight from the comments in settings.py ...
MEDIA_ROOT
MEDIA_ROOT is the absolute path to the directory where the media is stored, such as /home/media/media.lawrence.com/ .
MEDIA_URL
MEDIA_URL is the URL that processes the media that is served from MEDIA_ROOT . Be sure to use a trailing slash if there is a path component (optional in other cases). Examples: " http://media.lawrence.com ", " http://example.com/media/ ".
So, to change these words ... MEDIA_ROOT is where the files are physically located on your system, and MEDIA_URL is where these files are mapped. In development, this may not always be available, and in most cases your development environment and your production environment do not match, and you need to come back and change. Another thing is that this is NOT GOOD PRACTICE when Django was designed NOT for static content for you.
If you intend to use this in development, I suggest you use a method that restricts it to DEBUG = True . Telling Django to use static content from a temporary location during development when DEBUG set to True is much better and safer. You are not going to put DEBUG into operation, right? Well, at least not worth it.
Here's how I implemented it:
settings.py:
STATIC_DOC_ROOT = os.path.join(os.getcwd(), 'site_media')
urls.py:
from django.conf import settings
Thus, any project I'm working on has a site_media directory inside it with all the necessary media. In dev, it is autonomous, and I donβt need to flip any bits in the settings except DEBUG , which I would do anyway.
jathanism Feb 10 2018-10-10 14:40
source share