AppCommand
A management command which takes one or more installed application labels as arguments, and does something with each of them.
Attributes
| Attribute | Type | Description |
|---|---|---|
| missing_args_message | string = "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
| Name | Type | Description |
|---|---|---|
| parser | ArgumentParser | The argument parser instance to which the application label arguments will be added |
Returns
| Type | Description |
|---|---|
null | None |
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
| Name | Type | Description |
|---|---|---|
| *app_labels | string | One or more strings representing the labels of installed applications to be processed |
| **options | dict | Arbitrary keyword arguments representing parsed command line options |
Returns
| Type | Description |
|---|---|
string | A 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
| Name | Type | Description |
|---|---|---|
| app_config | [AppConfig](../../../apps/config/appconfig.md?sid=django_apps_config_appconfig) | The Django application configuration instance to be processed |
| **options | dict | Arbitrary keyword arguments representing parsed command line options |
Returns
| Type | Description |
|---|---|
string | The output generated by the command for the specific application configuration |