Command
This class starts a lightweight web server for development that also serves static files. It extends the base runserver command to provide additional arguments for controlling static file handling, such as disabling automatic serving or forcing it when debug mode is off. The class determines whether to wrap the default handler with a static files handler based on the provided configuration and environment settings.
Attributes
| Attribute | Type | Description |
|---|---|---|
| help | string | Starts a lightweight web server for development and also serves static files. |
Methods
add_arguments()
@classmethod
def add_arguments(
parser: ArgumentParser
) - > null
Configures the command line argument parser with additional flags for controlling static file serving behavior.
Parameters
| Name | Type | Description |
|---|---|---|
| parser | ArgumentParser | The argument parser instance to which the --nostatic and --insecure flags will be added. |
Returns
| Type | Description |
|---|---|
null | Nothing is returned; the parser object is modified in-place. |
get_handler()
@classmethod
def get_handler(
*args: tuple,
**options: dict
) - > [WSGIHandler](../../../../../core/handlers/wsgi/wsgihandler.md?sid=django_core_handlers_wsgi_wsgihandler)
Return the static files serving handler wrapping the default handler, if static files should be served. Otherwise return the default handler.
Parameters
| Name | Type | Description |
|---|---|---|
| *args | tuple | Variable length argument list passed to the parent handler initialization. |
| **options | dict | Configuration options containing 'use_static_handler' and 'insecure_serving' to determine if static files should be intercepted. |
Returns
| Type | Description |
|---|---|
[WSGIHandler](../../../../../core/handlers/wsgi/wsgihandler.md?sid=django_core_handlers_wsgi_wsgihandler) | A WSGI handler that either includes StaticFilesHandler middleware or the standard application handler based on the provided options. |