Command
This class provides a management command that identifies and displays differences between the current project settings and Django's default configuration. It supports multiple output formats, including a hash-style summary and a unified diff view, to highlight modified or custom settings. Users can optionally compare their configuration against a specific settings module instead of the global defaults.
Attributes
| Attribute | Type | Description |
|---|---|---|
| help | string | Displays differences between the current settings.py and Django's default settings. |
| requires_system_checks | list = [] | A list of system checks that must be performed before the command is executed, which is empty for this command. |
Methods
add_arguments()
@classmethod
def add_arguments(
parser: [CommandParser](../../base/commandparser.md?sid=django_core_management_base_commandparser)
)
Configures the command line argument parser with options for filtering settings and selecting output formats.
Parameters
| Name | Type | Description |
|---|---|---|
| parser | [CommandParser](../../base/commandparser.md?sid=django_core_management_base_commandparser) | The argument parser instance used to define CLI flags like --all, --default, and --output. |
handle()
@classmethod
def handle(
**options: dict
) - > string
Executes the command logic by comparing the current project settings against a default settings module and returning the formatted differences.
Parameters
| Name | Type | Description |
|---|---|---|
| **options | dict | A dictionary of parsed command line arguments including 'all', 'default', and 'output' format preferences. |
Returns
| Type | Description |
|---|---|
string | A newline-delimited string containing the formatted differences between the user settings and the default settings. |
output_hash()
@classmethod
def output_hash(
user_settings: dict,
default_settings: dict,
**options: dict
) - > list
Formats the settings differences using a key-value pair style where non-default or modified settings are flagged with hash marks.
Parameters
| Name | Type | Description |
|---|---|---|
| user_settings | dict | The dictionary of current active settings from the Django project. |
| default_settings | dict | The dictionary of settings from the comparison module or Django's global defaults. |
| **options | dict | Configuration options, specifically checking the 'all' flag to determine if unmodified settings should be included. |
Returns
| Type | Description |
|---|---|
list | A list of strings representing settings, where modified values are shown directly and new settings are suffixed with '###'. |
output_unified()
@classmethod
def output_unified(
user_settings: dict,
default_settings: dict,
**options: dict
) - > list
Formats the settings differences using a diff-like style, prefixing changes with plus and minus signs to indicate additions and modifications.
Parameters
| Name | Type | Description |
|---|---|---|
| user_settings | dict | The dictionary of current active settings from the Django project. |
| default_settings | dict | The dictionary of settings from the comparison module or Django's global defaults. |
| **options | dict | Configuration options, specifically checking the 'all' flag to determine if unmodified settings should be included in the output. |
Returns
| Type | Description |
|---|---|
list | A list of color-coded strings showing removed default values and added user values. |