Home Features Philosophy Docs Blog Errors Security Examples FAQ
DJE-032 Error Configuration

daphne not before staticfiles in INSTALLED_APPS

Error message

Static files not served correctly with daphne

When using daphne as the ASGI server, it must be listed before django.contrib.staticfiles in INSTALLED_APPS. Otherwise, daphne's runserver command will not properly take over from Django's default runserver, and static files may not be served correctly during development.

config daphne static

Affected versions: >=0.2.0

Solution

Before (problematic)
INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.staticfiles",
    "daphne",  # Too late!
    "djust",
    "myapp",
]
After (fixed)
INSTALLED_APPS = [
    "daphne",  # Must be first!
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.staticfiles",
    "djust",
    "myapp",
]