I’m confused about static files and media files in django. I’ve seen elsewhere that people use it interchangeably.
When should I use media_root and when should I use static_root?
If I have site images should I put it in static? And if I have product images do I put it in media?
MEDIA_ROOTis the directory where file uploads are placed, as well as where generated files are usually stored. For example, one of my Django apps allows users to upload images. In one of the model classes, I use theImageFieldtype from sorl-thumbnail withupload_to='%Y-%m'. Whenever a user uploads an image, the file is stored inMEDIA_ROOT/%Y-%m/(with%Yreplaced with the current year and%mreplaced with the current month number). Also, when sorl-thumbnail generates a thumbnail for an uploaded image, it places the thumbnail by default somewhere inMEDIA_ROOT/cache/.STATIC_ROOTis used to configure the directory where static assets are placed. For example, site stylesheets, JavaScript files, and images used in the design of web pages are the types of files that go intoSTATIC_ROOT. If you have multiple installed apps, each app that uses static files can have its own static files directory. You use thecollectstaticmanagement function (invoked viapython manage.py collectstatic) to copy all of the apps’ static files intoSTATIC_ROOT.