I just was looking for the answer and i'm still confused about it, in the end of the day i got two different answers:
is one of them right if not be direct and simple please so everybody can understand and by how to use them correctly i mean what kind of files to put in them exactly
Understanding the real difference between MEDIA_ROOT
and STATIC_ROOT
can be confusing sometimes as both of them are related to serving files.
To be clear about their differences, I could point out their uses and types of files they serve.
STATIC_ROOT, STATIC_URL and STATICFILES_DIRS
are all used to serve the static files required for the website or application. Whereas, MEDIA_URL and MEDIA_ROOT
are used to serve the media files uploaded by a user.As you can see that the main difference lies between media and static files. So, let's differentiate them.
So, if there is a JavaScript file named main.js
which is used to give some functionalities like show popup on button click then it is a STATIC file. Similarly, images like website logo, or some static images displayed in the website that the user can't change by any action are also STATIC files.
Hence, files(as mentioned above) that are used during the development and rendering of the website are known as STATIC files and are served by STATIC_ROOT, STATIC_URL or STATICFILES_DIRS(during deployment) in Django.
Now for the MEDIA files: any file that the user uploads, for example; a video, or image or excel file, etc. during the normal usage of the website or application are called MEDIA files in Django.
MEDIA_ROOT and MEDIA_URL are used to point out the location of MEDIA files stored in your application.
Hope this makes you clear.