Come usare Django con DaphneLink to this heading

Daphne is a pure-Python ASGI server for UNIX, maintained by members of the Django project. It acts as the reference server for ASGI.

Installare DaphneLink to this heading

You can install Daphne with pip:

Shell
python -m pip install daphne

Eseguire Django con DaphneLink to this heading

Quando Daphne è installato, è disponibile un comando daphne che avvia il processo server. Nella sua forma più semplice, Daphne necessita di essere chiamato con la locazione di un modulo che contiene un oggetto di applicazione ASGI, seguito da come si chiama l’applicazione (separati dai due punti).

For a typical Django project, invoking Daphne would look like:

Shell
daphne myproject.asgi:application

Questo avvierà il processo che ascolta su 127.0.0.1:8000. Richiede che il tuo progetto sia sul percorso di Python; per assicurartene, lancia questo comando dalla stessa directory del tuo file manage.py.

Integration with runserverLink to this heading

Daphne provides a runserver command to serve your site under ASGI during development.

This can be enabled by adding daphne to the start of your INSTALLED_APPS and adding an ASGI_APPLICATION setting pointing to your ASGI application object:

Code
INSTALLED_APPS = [
    "daphne",
    ...,
]

ASGI_APPLICATION = "myproject.asgi.application"