Command
Overview
The base class from which all management commands ultimately derive.
Use this class if you want access to all of the mechanisms which parse the command-line arguments and work out what code to call in response; if you don't need to change any of that behavior, consider using one of the subclasses defined in this file.
If you are interested in overriding/customizing various aspects of the command-parsing and -execution behavior, the normal flow works as follows:
django-adminormanage.pyloads the command class and calls itsrun_from_argv()method.The
run_from_argv()method callscreate_parser()to get anArgumentParserfor the arguments, parses them, performs any environment changes requested by options likepythonpath, and then calls theexecute()method, passing the parsed arguments.The
execute()method attempts to carry out the command by calling thehandle()method with the parsed arguments; any output produced byhandle()will be printed to standard output and, if the command is intended to produce a block of SQL statements, will be wrapped inBEGINandCOMMIT.If
handle()orexecute()raised any exception (e.g.CommandError),run_from_argv()will instead print an error message tostderr.
Thus, the handle() method is typically the starting point for subclasses; many built-in commands and command types either place all of their logic in handle(), or perform some additional parsing work in handle() and then delegate from it to more specialized methods as needed.
Several attributes affect behavior at various steps along the way:
help A short description of the command, which will be printed in help messages.
output_transaction A boolean indicating whether the command outputs SQL statements; if True, the output will automatically be wrapped with BEGIN; and COMMIT;. Default value is False.
requires_migrations_checks A boolean; if True, the command prints a warning if the set of migrations on disk don't match the migrations in the database.
requires_system_checks A list or tuple of tags, e.g. [Tags.staticfiles, Tags.models]. System checks registered in the chosen tags will be checked for errors prior to executing the command. The value 'all' can be used to specify that all system checks should be performed. Default value is 'all'.
To validate an individual application's models
rather than all applications' models, call
``self.check(app_configs)`` from ``handle()``, where ``app_configs``
is the list of application's configuration provided by the
app registry.
stealth_options A tuple of any options the command uses which aren't defined by the argument parser.
_create_and_get_empty_migration
Signature
_create_and_get_empty_migration(self, app_label)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| app_label | yes |
Source
server/vueda/user/management/commands/makegroupmigrations.py:363
_get_generated_date_for_vueda_generated_migration
Signature
_get_generated_date_for_vueda_generated_migration(self, app_name, migration_name)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| app_name | yes | ||
| migration_name | yes |
Source
server/vueda/user/management/commands/makegroupmigrations.py:340
_get_project_dependency_migration_names_from_show_migrations
Signature
_get_project_dependency_migration_names_from_show_migrations(self, exclude)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| exclude | yes |
Source
server/vueda/user/management/commands/makegroupmigrations.py:445
_get_vueda_generated_migration_data_for_auth_user_model
Signature
_get_vueda_generated_migration_data_for_auth_user_model(self)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes |
Source
server/vueda/user/management/commands/makegroupmigrations.py:463
_rewrite_migration
Signature
_rewrite_migration(self, migration_file, changes, dependencies)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| migration_file | yes | ||
| changes | yes | ||
| dependencies | yes |
Source
server/vueda/user/management/commands/makegroupmigrations.py:402
add_arguments
Entry point for subclassed commands to add custom arguments.
Signature
add_arguments(self, parser)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| parser | yes |
Source
server/vueda/user/management/commands/makegroupmigrations.py:324
handle
The actual logic of the command. Subclasses must implement this method.
Signature
handle(self, options)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| options | yes |
Source
server/vueda/user/management/commands/makegroupmigrations.py:499
help
Source
server/vueda/user/management/commands/makegroupmigrations.py:315