Skip to content
Branch: master
Find file Copy path
Find file Copy path
9 contributors

Users who have contributed to this file

@timgraham @jezdez @jdufresne @claudep @mlorant @carljm @desecho @ChillarAnand @alex
33 lines (28 sloc) 1.29 KB
from django.conf import settings
from django.contrib.staticfiles.handlers import StaticFilesHandler
from import (
Command as RunserverCommand,
class Command(RunserverCommand):
help = "Starts a lightweight Web server for development and also serves static files."
def add_arguments(self, parser):
'--nostatic', action="store_false", dest='use_static_handler',
help='Tells Django to NOT automatically serve static files at STATIC_URL.',
'--insecure', action="store_true", dest='insecure_serving',
help='Allows serving static files even if DEBUG is False.',
def get_handler(self, *args, **options):
Return the static files serving handler wrapping the default handler,
if static files should be served. Otherwise return the default handler.
handler = super().get_handler(*args, **options)
use_static_handler = options['use_static_handler']
insecure_serving = options['insecure_serving']
if use_static_handler and (settings.DEBUG or insecure_serving):
return StaticFilesHandler(handler)
return handler
You can’t perform that action at this time.