# Buggy code
def handle(self, *args, **options):
    # Gather all available reports
    reports = get_reports()

    # Run reports
    for module_name, report_list in reports:
        for report in report_list:
            if (
                module_name in options["reports"]
                or report.full_name in options["reports"]
            ):
                # Run the report and create a new ReportResult
                self.stdout.write(
                    "[{:%H:%M:%S}] Running {}...".format(
                        timezone.now(), report.full_name
                    )
                )
                report.run()

                # Report on success/failure
                status = (
                    self.style.ERROR("FAILED")
                    if report.failed
                    else self.style.SUCCESS("SUCCESS")
                )
                for test_name, attrs in report.result.data.items():
                    self.stdout.write(
                        "\t{}: {} success, {} info, {} warning, {} failure".format(
                            test_name,
                            attrs["success"],
                            attrs["info"],
                            attrs["warning"],
                            attrs["failure"],
                        )
                    )
                self.stdout.write(
                    "[{:%H:%M:%S}] {}: {}".format(
                        timezone.now(), report.full_name, status
                    )
                )

    # Wrap things up
    self.stdout.write("[{:%H:%M:%S}] Finished".format(timezone.now()))


# Traceback (TypeError)
$ python3 manage.py runreport DeviceConnectionsReport
[17:50:53] Running DeviceConnectionsReport.DeviceConnectionsReport...
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/opt/netbox/netbox/extras/management/commands/runreport.py", line 27, in handle
report.run()
TypeError: run() missing 1 required positional argument: 'job_result'

# Fixed code
def handle(self, *args, **options):
    # Gather all available reports
    reports = get_reports()

    # Run reports
    for module_name, report_list in reports:
        for report in report_list:
            if (
                module_name in options["reports"]
                or report.full_name in options["reports"]
            ):
                # Run the report and create a new ReportResult
                self.stdout.write(
                    "[{:%H:%M:%S}] Running {}...".format(
                        timezone.now(), report.full_name
                    )
                )

                report_content_type = ContentType.objects.get(
                    app_label="extras", model="report"
                )
                job_result = JobResult.enqueue_job(
                    run_report, report.full_name, report_content_type, None
                )

                # Wait on the job to finish
                while (
                    job_result.status
                    not in JobResultStatusChoices.TERMINAL_STATE_CHOICES
                ):
                    time.sleep(1)
                    job_result = JobResult.objects.get(pk=job_result.pk)

                # Report on success/failure
                if job_result.status == JobResultStatusChoices.STATUS_FAILED:
                    status = self.style.ERROR("FAILED")
                elif job_result == JobResultStatusChoices.STATUS_ERRORED:
                    status = self.style.ERROR("ERRORED")
                else:
                    status = self.style.SUCCESS("SUCCESS")

                for test_name, attrs in job_result.data.items():
                    self.stdout.write(
                        "\t{}: {} success, {} info, {} warning, {} failure".format(
                            test_name,
                            attrs["success"],
                            attrs["info"],
                            attrs["warning"],
                            attrs["failure"],
                        )
                    )
                self.stdout.write(
                    "[{:%H:%M:%S}] {}: {}".format(
                        timezone.now(), report.full_name, status
                    )
                )
                self.stdout.write(
                    "[{:%H:%M:%S}] {}: Duration {}".format(
                        timezone.now(), report.full_name, job_result.duration
                    )
                )

    # Wrap things up
    self.stdout.write("[{:%H:%M:%S}] Finished".format(timezone.now()))