Skip to main content

uWSGI as a Django management command

Project description


Run pyuwsgi (aka uWSGI) as a Django management command.

build status pypi pyversions


  1. Install:

    pip install django-pyuwsgi

       # ...
       # ...
  3. Run: pyuwsgi --socket=:8000 ...


Pyuwsgi already knows the Python interpreter and virtualenv (if applicable) to use from the Django management command environment. By default, it will run with the following flags (using settings.WSGI_APPLICATION to determine the module):

--strict --need-app --module={derived}

If you have STATIC_URL defined with a local URL, it will also add --static-map, derived from STATIC_URL and STATIC_ROOT.

You can pass any additional arguments uWSGI accepts in from the command line.

But uWSGI has a lot of flags, and many of them, you want every time you run the project. For that scenario, you can configure your own defaults using the optional setting, PYUWSGI_ARGS. Here's an example you might find helpful:

    ":".join(WSGI_APPLICATION.rsplit(".", 1)),
    "=".join([STATIC_URL.rstrip("/"), STATIC_ROOT]),
    "/* 7776000",

Don't forget to also set something like --socket=:8000 or --http=:8000 so your app listens on a port. Depending on your setup, it may make more sense to pass this in via the command line than hard-coding it in your settings.


In some scenarios, it is beneficial to distribute a Django project with a single entrypoint for command-line interaction. This can come in handy when building Docker containers or self-contained Python apps with something like shiv.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-pyuwsgi, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size django_pyuwsgi-1.1.0-py2.py3-none-any.whl (5.3 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-pyuwsgi-1.1.0.tar.gz (3.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page