From b2842f1ef1d2365971268a351b39ed9741b539bd Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Thu, 23 Feb 2017 17:51:39 -0800 Subject: [PATCH] Fixed #542: Don't use staticfiles handler if staticfiles is not installed --- channels/management/commands/runserver.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/channels/management/commands/runserver.py b/channels/management/commands/runserver.py index 9733559..7caccbe 100644 --- a/channels/management/commands/runserver.py +++ b/channels/management/commands/runserver.py @@ -3,6 +3,7 @@ import sys import threading from daphne.server import Server, build_endpoint_description_strings +from django.apps import apps from django.conf import settings from django.core.management.commands.runserver import Command as RunserverCommand from django.utils import six @@ -139,7 +140,8 @@ class Command(RunserverCommand): if static files should be served. Otherwise just returns the default handler. """ - use_static_handler = options.get('use_static_handler', True) + staticfiles_installed = apps.is_installed("django.contrib.staticfiles") + use_static_handler = options.get('use_static_handler', staticfiles_installed) insecure_serving = options.get('insecure_serving', False) if use_static_handler and (settings.DEBUG or insecure_serving): return StaticFilesConsumer()