Skip to main content

AppCommand

A management command which takes one or more installed application labels as arguments, and does something with each of them.

Attributes

AttributeTypeDescription
missing_args_messagestring = "Enter at least one application label."The error message displayed to the user when no application labels are provided as command-line arguments.

Methods


add_arguments()

@classmethod
def add_arguments(
parser: ArgumentParser
) - > null

Configures the command line argument parser to accept one or more application labels as positional arguments.

Parameters

NameTypeDescription
parserArgumentParserThe argument parser instance to which the application label arguments will be added

Returns

TypeDescription
nullNone

handle()

@classmethod
def handle(
*app_labels: string,
**options: dict
) - > string

Retrieves the application configurations for the provided labels and executes the command logic for each one.

Parameters

NameTypeDescription
*app_labelsstringOne or more strings representing the labels of installed applications to be processed
**optionsdictArbitrary keyword arguments representing parsed command line options

Returns

TypeDescription
stringA single string containing the concatenated output from each processed application configuration, separated by newlines

handle_app_config()

@classmethod
def handle_app_config(
app_config: [AppConfig](../../../apps/config/appconfig.md?sid=django_apps_config_appconfig),
**options: dict
) - > string

Perform the command's actions for app_config, an AppConfig instance corresponding to an application label given on the command line.

Parameters

NameTypeDescription
app_config[AppConfig](../../../apps/config/appconfig.md?sid=django_apps_config_appconfig)The Django application configuration instance to be processed
**optionsdictArbitrary keyword arguments representing parsed command line options

Returns

TypeDescription
stringThe output generated by the command for the specific application configuration