---
source: https://iinventedlight.com/library/notes/django-asgi-uvicorn.md
title: "Run a Django project on Uvicorn as an ASGI app"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (Django (GitHub docs)); BSD-3-Clause (Starlette docs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Django (GitHub docs), How to use Django with Uvicorn; Starlette docs, Applications. BSD-3-Clause; BSD-3-Clause."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: Django ASGI deployment with Uvicorn"
tags: [django, asgi, uvicorn, starlette, deployment, gunicorn]
client: Librarian
sources:
  - id: S1
    title: "How to use Django with Uvicorn"
    publisher: Django (GitHub docs)
    url: https://raw.githubusercontent.com/django/django/main/docs/howto/deployment/asgi/uvicorn.txt
    accessed: 2026-11-19
    license: "BSD-3-Clause"
  - id: S2
    title: "Applications"
    publisher: Starlette docs
    url: https://starlette.dev/applications/
    accessed: 2026-11-19
    license: "BSD-3-Clause"
---
# Run a Django project on Uvicorn as an ASGI app
**Answer:** Uvicorn is an ASGI server based on `uvloop` and `httptools`, with an emphasis on speed. For a typical Django project, invoking Uvicorn would look like `python -m uvicorn myproject.asgi:application`. A `Starlette` application serves incoming HTTP and WebSocket requests.

## Run Django in Uvicorn

Install Uvicorn with `python -m pip install uvicorn`. When Uvicorn is installed, a `uvicorn` command is available which runs ASGI applications. Call Uvicorn with a module that contains an ASGI application object, then a colon and the application name. This starts a process listening on `127.0.0.1:8000`. Your project must be on the Python path; run the command from the same directory as `manage.py`. In development mode, add `--reload` so the server reloads when a file is changed on disk.

Gunicorn is a robust web server with process monitoring and automatic restarts, which can help when running Uvicorn in production. To install Uvicorn and Gunicorn, use `python -m pip install uvicorn uvicorn-worker gunicorn`. Then start Gunicorn using the Uvicorn worker.

## The ASGI application object

Starlette includes an application class `Starlette` that nicely ties together all of its other functionality. You pass `routes` (a list of routes to serve incoming HTTP and WebSocket requests), `middleware` (a list of middleware to run for every request), and an optional `lifespan`. In the docs, a `lifespan` function prints `Startup`, then `yield`, then `Shutdown`.

| myproject.asgi:application | --reload |
|---|---|
| `myproject.asgi:application` | Module and the ASGI application name |
| `--reload` | Reload when a file is changed on disk |
| `uvicorn-worker` | A Gunicorn worker |
| `lifespan` | Startup, `yield`, and Shutdown |

## See also

- [django-views](https://iinventedlight.com/library/notes/django-views/)
- [fastapi-async-await](https://iinventedlight.com/library/notes/fastapi-async-await/)
- [django-request-response](https://iinventedlight.com/library/notes/django-request-response/)

## Claims

- id: C1
  claim: Uvicorn is an ASGI server you call with module:application.
  source: S1
  evidence: "Uvicorn needs to be called with the location of a module"

- id: C3
  claim: A typical Django command is python -m uvicorn myproject.asgi:application.
  source: S1
  evidence: "python -m uvicorn myproject.asgi:application"

- id: C4
  claim: Starlette applications take routes, middleware, and a lifespan.
  source: S2
  evidence: "Creates a Starlette application"

## Sources

- [S1] How to use Django with Uvicorn. Django (GitHub docs). https://raw.githubusercontent.com/django/django/main/docs/howto/deployment/asgi/uvicorn.txt . License: BSD-3-Clause. Accessed 2026-11-19.

- [S2] Applications. Starlette docs. https://starlette.dev/applications/ . License: BSD-3-Clause. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Django (GitHub docs), How to use Django with Uvicorn; Starlette docs, Applications. BSD-3-Clause; BSD-3-Clause. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
