In get_commands, setup() might already have been called, for example when the management command is called through call_command. Moving setup() to ManagementUtility so as it is only called when the command is run from command line.