---
title: "Comment utiliser Django avec Uvicorn"
version: 4.1
locale: fr
source: https://docs.djangoproject.com/fr/4.1/howto/deployment/asgi/uvicorn/
canonical: https://djangodocs.dev/fr/4.1/howto/deployment/asgi/uvicorn/
---
# Comment utiliser Django avec Uvicorn

[Uvicorn](https://www.uvicorn.org/) est un serveur ASGI basé sur `uvloop` et `httptools`, avec un accent sur la vitesse.

## Installation de Uvicorn

Vous pouvez installer Uvicorn avec `pip`:

```bash
python -m pip install uvicorn
```

## Lancement de Django dans Uvicorn

Lorsque Uvicorn est installé, une commande `uvicorn` est disponible qui exécute des applications ASGI. Uvicorn a besoin d’être appelé avec l’emplacement d’un module contenant un objet d’application ASGI, suivi par le nom donné à l’application (séparés par un deux-points).

Pour un projet Django typique, l’invocation de Uvicorn pourrait ressembler à ceci :

```bash
python -m uvicorn myproject.asgi:application
```

Cela démarrera un processus écoutant sur `127.0.0.1: 8000`. Il faut que votre projet soit dans le chemin Python ; pour s’en assurer, exécutez cette commande dans le même répertoire que votre fichier `manage.py`.

In development mode, you can add `--reload` to cause the server to reload any
time a file is changed on disk.

Pour une utilisation plus avancée, lisez la [documentation Uvicorn](https://www.uvicorn.org/).

## Deploying Django using Uvicorn and Gunicorn

[Gunicorn](https://gunicorn.org/) is a robust web server that implements process monitoring and automatic
restarts. This can be useful when running Uvicorn in a production environment.

To install Uvicorn and Gunicorn, use the following:

```bash
python -m pip install uvicorn gunicorn
```

Then start Gunicorn using the Uvicorn worker class like this:

```bash
python -m gunicorn myproject.asgi:application -k uvicorn.workers.UvicornWorker
```
