Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Django do with `MEDIA_ROOT`?

Tags:

python

django

What does Django do with MEDIA_ROOT exactly? I never understood it. Since Django itself doesn't serve static media, and you have to set up apache or something similar for it, why does it care in which directory it sits?

like image 788
Ram Rachum Avatar asked Feb 20 '10 18:02

Ram Rachum


2 Answers

You're not the only one who wonders; check out Django ticket #10650. Based on the comments by Django developers there, I think this pretty much sums up what MEDIA_ROOT is used for:

Unfortunately, Django is also at fault for being far too vague in its docs about what MEDIA_ROOT and MEDIA_URL are used for. Searching through Django's code confirms that MEDIA_ROOT & MEDIA_URL are used for file upload, and that MEDIA_URL is provided as a convenience to templates via the default context processors (available when using RequestContext??).

like image 187
mjjohnson Avatar answered Oct 06 '22 08:10

mjjohnson


It appears to be used by some classes in Django as a default -- for instance, FileSystemStorage uses it as the default place to store files.

like image 30
Michael Williamson Avatar answered Oct 06 '22 06:10

Michael Williamson