Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django - MEDIA_ROOT and MEDIA_URL

Could you please suggest me the good documentation where I can understand the MEDIA_URL and MEDIA_ROOT? It's really confusing me.

like image 540
Sivasubramaniam Arunachalam Avatar asked Jan 27 '11 18:01

Sivasubramaniam Arunachalam


1 Answers

The MEDIA_ROOT is the path on the filesystem to the directory containing your static media.

The MEDIA_URL is the URL that makes the static media accessible over HTTP.

The docs: http://docs.djangoproject.com/en/1.2/ref/settings/#media-root

The main idea is that serving things through python+django is expensive. Since your media is static you don't need to pay that cost, so you serve it differently (e.g. directly via nginx or through a CDN). However, you still need to know where the media is located in the file system (e.g. for file uploads) and what the URL is (e.g. to put in templates). The settings exist to tie all that together.

like image 107
rz. Avatar answered Oct 03 '22 22:10

rz.