Static File Serving
In the introduction, we mentioned that Django includes a view function called static
that serves static files. The first important point to make regarding the serving of static files is that Django is not intended to serve them in production. It is not Django's role, and in production, Django will refuse to serve static files. This is normal and intended behavior. If Django is just reading from the filesystem and sending out a file, then it has no advantage over a normal web server, which would probably be more performant at this task. Furthermore, if you serve static files with Django, you will keep the Python process busy for the duration of the request and it will be unable to serve the dynamic requests to which it is more suited.
For these reasons, the Django static
view is designed only for use during development and will not work if your DEBUG
setting is False
. Since during development we only usually have one person accessing the site at a time (the...