Skip to content

Latest commit

 

History

History

management_command_alias

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Simple Management Command Aliases

July 2023

A simple way to add management command aliases can be to simply map the argv inputs to execute_from_command_line() in manage.py:

def alias_map(argv):
    if len(argv) > 1:
        argv[1:2] = settings.COMMAND_ALIASES.get(argv[1], argv[1]).split(" ")
    return argv

if __name__ == "__main__":
    execute_from_command_line(alias_map(sys.argv))

then in your settings:

COMMAND_ALIASES = {
    "mm": "makemigrations --no-header",
    "sp": "shell_plus",
}