Introduction to Static Files Finder
There are three times when Django needs to locate static files on disk, and for this, it uses static file finder. It can be thought of as a plugin. It is a class that implements methods for converting URL paths into disks and iterates through the project directory to find static files.
The first time Django does this is when the Django static
view receives a request to load a particular static file; here, it needs to convert the path in the URL into a location on disk. For example, let’s say the URL’s path is /static/logo.png
, and it is converted into the bookr/static/logo.png
path on the disk. As we noted in the previous section, this only happens during development. On a production server, Django should not receive this request as it will be handled directly by the web server.
The second time is when using the collectstatic
management command. This gathers all the static files in the project directory and copies them to a single...