Install WhiteNoise
Learn all about Install WhiteNoise in this comprehensive tutorial.
- •Django does not have a built-in solution for serving static files, at least not in production when DEBUG has to be False.
- •To install WhiteNoise in your virtual environment, type the command below:
- •To make Django aware of you wanting to run WhitNoise, you have to specify it in the MIDDLEWARE list in settings.
- •There are one more action you have to perform before you can serve the static file from the example in the previous chapter.
WhiteNoise
Django does not have a built-in solution for serving static files, at least not in production when DEBUG has to be False.
We have to use a third-party solution to accomplish this.
In this Tutorial we will use WhiteNoise, which is a Python library, built for serving static files.
Install WhiteNoise
To install WhiteNoise in your virtual environment, type the command below:
The result should be something like this:
Modify Settings
To make Django aware of you wanting to run WhitNoise, you have to specify it in the MIDDLEWARE list in settings.py file:
Collect Static Files
There are one more action you have to perform before you can serve the static file from the example in the previous chapter. You have to collect all static files and put them into one specified folder. You will learn how in the next chapter.
Module quiz
2 questionsWhich of the following is true about Install WhiteNoise?
What is the most common pitfall when working with Install WhiteNoise?
Answer all questions to submit.