MCPcopy
hub / github.com/django/django / get_commands

Function get_commands

django/core/management/__init__.py:53–80  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

51
52@functools.cache
53def 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
83def call_command(command_name, *args, **options):

Callers 5

call_commandFunction · 0.85
main_help_textMethod · 0.85
fetch_commandMethod · 0.85
autocompleteMethod · 0.85

Calls 4

find_commandsFunction · 0.85
get_app_configsMethod · 0.80
joinMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected