From 1502de002cf3cd26bd3523b1a078a50e8023bbe4 Mon Sep 17 00:00:00 2001 From: Thomas Fossati Date: Fri, 23 May 2025 20:29:43 +0200 Subject: [PATCH] Remove --nostatic and --insecure args to runserver command if staticfiles app is not installed. (#559) --- daphne/management/commands/runserver.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/daphne/management/commands/runserver.py b/daphne/management/commands/runserver.py index 7e67e07..d505f33 100644 --- a/daphne/management/commands/runserver.py +++ b/daphne/management/commands/runserver.py @@ -73,18 +73,19 @@ class Command(RunserverCommand): "seconds (default: 5)" ), ) - parser.add_argument( - "--nostatic", - action="store_false", - dest="use_static_handler", - help="Tells Django to NOT automatically serve static files at STATIC_URL.", - ) - parser.add_argument( - "--insecure", - action="store_true", - dest="insecure_serving", - help="Allows serving static files even if DEBUG is False.", - ) + if apps.is_installed("django.contrib.staticfiles"): + parser.add_argument( + "--nostatic", + action="store_false", + dest="use_static_handler", + help="Tells Django to NOT automatically serve static files at STATIC_URL.", + ) + parser.add_argument( + "--insecure", + action="store_true", + dest="insecure_serving", + help="Allows serving static files even if DEBUG is False.", + ) def handle(self, *args, **options): self.http_timeout = options.get("http_timeout", None)