Skip to main content

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

AttributeTypeDescription
helpstringDisplays differences between the current settings.py and Django's default settings.
requires_system_checkslist = []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

NameTypeDescription
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

NameTypeDescription
**optionsdictA dictionary of parsed command line arguments including 'all', 'default', and 'output' format preferences.

Returns

TypeDescription
stringA 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

NameTypeDescription
user_settingsdictThe dictionary of current active settings from the Django project.
default_settingsdictThe dictionary of settings from the comparison module or Django's global defaults.
**optionsdictConfiguration options, specifically checking the 'all' flag to determine if unmodified settings should be included.

Returns

TypeDescription
listA 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

NameTypeDescription
user_settingsdictThe dictionary of current active settings from the Django project.
default_settingsdictThe dictionary of settings from the comparison module or Django's global defaults.
**optionsdictConfiguration options, specifically checking the 'all' flag to determine if unmodified settings should be included in the output.

Returns

TypeDescription
listA list of color-coded strings showing removed default values and added user values.