How to Start Django Project on Waitress Server (Windows) [Easy-Way]

How to Start Django Project on Waitress Server (Windows) [Easy-Way]

Step-by-step guide:

  1. Check project structure
  2. Install required libraries
  3. Create file
  4. Edit file
  5. Edit file
  6. Run command for running the server

yourdjangoprojectname is the name of your project. I'm just using it here as a project name.

Check Project Structure

├── yourdjangoprojectname
│   ├──
│   ├──
│   ├──
│   ├──

Install Required Libraries

pip install waitress
pip install whitenoise

Edit File

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "yourdjangoprojectname.settings")

# for using WhiteNoise:
from whitenoise import WhiteNoise
application = WhiteNoise(get_wsgi_application())

Create File

from waitress import serve
from yourdjangoprojectname.wsgi import application
if __name__ == '__main__':
    serve(application, port='8000')

Edit File

For WhiteNoise to work we need to add middleware for WhiteNoise.

    # ...
    # ...

Run Command for Running the Server

You can run the project on the Waitress server by simply typing the command.


Leave a Reply

Your email address will not be published. Required fields are marked *