36
You need to look in the django.core.management
package; the execute_from_command_line()
function accepts the sys.argv
command line parameters and takes it from there.
When you enter manage.py startapp xyz
on the command line, sys.argv
is set to ['manage.py', 'startapp', 'xyz']
.
These are handed off to a ManagementUtility
instance, which has a .execute()
method to do the actual parsing.
The whole django.core.management
package is modular; the .commands
sub package contains the various standard commands for the manage.py
tool. django.core.management.commands.startapp
handles the startapp
subcommand, for example.
Source:stackexchange.com