Return a dictionary mapping command names to their callback applications. Look for a management.commands package in django.core, and in each installed application -- if a commands package exists, register all commands in that package. Core commands are always included. If a se
()
| 51 | |
| 52 | @functools.cache |
| 53 | def get_commands(): |
| 54 | """ |
| 55 | Return a dictionary mapping command names to their callback applications. |
| 56 | |
| 57 | Look for a management.commands package in django.core, and in each |
| 58 | installed application -- if a commands package exists, register all |
| 59 | commands in that package. |
| 60 | |
| 61 | Core commands are always included. If a settings module has been |
| 62 | specified, also include user-defined commands. |
| 63 | |
| 64 | The dictionary is in the format {command_name: app_name}. Key-value |
| 65 | pairs from this dictionary can then be used in calls to |
| 66 | load_command_class(app_name, command_name) |
| 67 | |
| 68 | The dictionary is cached on the first call and reused on subsequent |
| 69 | calls. |
| 70 | """ |
| 71 | commands = {name: "django.core" for name in find_commands(__path__[0])} |
| 72 | |
| 73 | if not settings.configured: |
| 74 | return commands |
| 75 | |
| 76 | for app_config in reversed(apps.get_app_configs()): |
| 77 | path = os.path.join(app_config.path, "management") |
| 78 | commands.update({name: app_config.name for name in find_commands(path)}) |
| 79 | |
| 80 | return commands |
| 81 | |
| 82 | |
| 83 | def call_command(command_name, *args, **options): |
no test coverage detected