Fixed #542: Don't use staticfiles handler if staticfiles is not installed

This commit is contained in:
Andrew Godwin 2017-02-23 17:51:39 -08:00
parent 7ab21c4846
commit b2842f1ef1

View File

@ -3,6 +3,7 @@ import sys
import threading import threading
from daphne.server import Server, build_endpoint_description_strings from daphne.server import Server, build_endpoint_description_strings
from django.apps import apps
from django.conf import settings from django.conf import settings
from django.core.management.commands.runserver import Command as RunserverCommand from django.core.management.commands.runserver import Command as RunserverCommand
from django.utils import six from django.utils import six
@ -139,7 +140,8 @@ class Command(RunserverCommand):
if static files should be served. Otherwise just returns the default if static files should be served. Otherwise just returns the default
handler. 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) insecure_serving = options.get('insecure_serving', False)
if use_static_handler and (settings.DEBUG or insecure_serving): if use_static_handler and (settings.DEBUG or insecure_serving):
return StaticFilesConsumer() return StaticFilesConsumer()