How can I use Sentry to track the output of a Django management command?

I’m trying to use Sentry to track the output of management commands run on a production server. I’m currently using Sentry via the DjangoIntegration in my settings.py file:

# Sentry Configuration
sentry_sdk.init(
    dsn=os.environ.get('SENTRY_DSN'),
    integrations=[DjangoIntegration(), CeleryIntegration()],
    environment='production',
)

I’ve set up a test management command raise_exception.py as follows:

from django.core.management.base import BaseCommand


class Command(BaseCommand):
    help = 'Raise a simple Exception to test error handlers.'

    def handle(self, *args, **options):
        raise Exception("This is a test.")

Currently the exception does not get sent to Sentry. How can I send an error from a Management command to Sentry?

Python version: 3.7.0
Django version: 2.2.10
Sentry SDK: 0.14.3

Thanks for any support!

I have the same problem, did you find a solution ? thank you in advance

Do you have iPython installed?
I had the same issue and once i uninstalled iPython i could trace exception to sentry even from the python manage.py