'Runs a management command job'

def run_management_command(self):

    from django.core.management import call_command
    (args, options) = self.get_args()
    stdout = StringIO()
    stderr = StringIO()
    ostdout = sys.stdout
    ostderr = sys.stderr
    sys.stdout = stdout
    sys.stderr = stderr
    (stdout_str, stderr_str, exception_str) = ('', '', '')
    try:
        call_command(self.command, *args, **options)
    except Exception as e:
        exception_str = self._get_exception_string(e, sys.exc_info())
        self.last_run_successful = False
    sys.stdout = ostdout
    sys.stderr = ostderr
    stdout_str = stdout.getvalue()
    stderr_str = stderr.getvalue()
    return (stdout_str, (stderr_str + exception_str))
