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 serving static files is that Django does not intend 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 will probably be more performant at this task. Further, if you serve static files with Django, you will keep the Python process busy for the duration of this request and it will be unable to serve the dynamic requests for 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 usually only have one person accessing the site at a time (the developer...