Static file finders – use during collectstatic
Once we have finished working on our static files, they need to be moved into a specific directory that can be served by our production web server. We can then deploy our website by copying our Django code and static files to our production web server. In the case of business_site
, we will want to move logo.png
and main.css
(along with other static files that Django itself includes) into a single directory that can be copied to the production web server. This is the role of the collectstatic
management command.
We have already discussed how Django uses static file finders during request handling. Now, we will cover the other use case: collecting static files for deployment. Upon running the collectstatic
management command, Django uses each finder to list static files on the disk. Every static file that is found is then copied into the STATIC_ROOT
directory (also defined in settings.py
). This is a little bit like the reverse...