🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to Django Notes
Topic #40

Install WhiteNoise


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:

pip install whitenoise

The result should be something like this:

Collecting whitenoise
  Downloading whitenoise-6.9.0-py3-none-any.whl.metadata (3.6 kB)
Downloading whitenoise-6.9.0-py3-none-any.whl (20 kB)
Installing collected packages: whitenoise
Successfully installed whitenoise-6.9.0

[notice] A new release of pip is available: 24.3.1 -> 25.0.1
[notice] To update, run: python.exe -m pip install --upgrade pip

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:

.
.
MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',
].
.

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.

Want to go beyond the notes?

Join CodingNow 2.0's Django course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Install WhiteNoise – FAQs

Quick answers about learning Install WhiteNoise in Django.

This free note from CodingNow 2.0 explains Install WhiteNoise in Django — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Django topic on CodingNow 2.0, including Install WhiteNoise, is 100% free with no signup required.
With focused practice, most students grasp Install WhiteNoise in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now