How to setup Whitenoise for a Django project

Hello, welcome to the devmaesters website. In this post I am going to show you how you can setup Whitenoise in your Django project to  serve your staticfiles in a production environment.


Whitenoise is a very usefull pip package that allows you to configure your Django project to serve its own staticfiles so it can deploy anywhere without depending on service providers.

Follow the steps below to setup Whitenoise in your Django project.

Step 1

Install the Whitenoise package locally by executing the command below in your terminal.

pip install whitenoise

Step 2

Go to your project's and add the app to the installed app list.

    'whitenoise.runserver_nostatic',  #add this line  

Step 3

In the middleware section of add the Whitenoise middleware. 

    "whitenoise.middleware.WhiteNoiseMiddleware", #add this line

Step 4

Add this line to your file

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_STORAGE=""#add this line



And that's it, following the steps listed above will make it easy to enable staticfiles on hosting platform that require you to serve your own staticfiles e.g Heroku and Railway. 


Hello, my name is Abubakar Zakari. Am a budding fullstack developer from Nigeria who loves developing softwares and learning new frameworks and langauges.


Select image

No comment yet




Frontend Development |Backend Development |Full Website Development |Bootstrap Website upgrades | Website Debbugging | Website Hosting & deployment


Interested in hiring me or collaborating with me on a project, click on any of the links below to get my social media handle

Or contact me via Tel: (+234)-806-225-7480 | Email:
Privacy Policy

By using our website,
you agree that devmaesters can store cookies on your device and disclose information in accordance with our privacy policy.