We are running custom management commands periodically on the server.
Is there any way to get something like error reporting via email working for the command?
django-admin is Django's command-line utility for administrative tasks. This document outlines all it can do. In addition, manage.py is automatically created in each Django project.
An exception is an abnormal event that leads to program failure. To deal with this situation, Django uses its own exception classes and supports all core Python exceptions as well. Django core exceptions classes are defined in django. core.
It is your tool for executing many Django-specific tasks -- starting a new app within a project, running the development server, running your tests... It is also an extension point where you can access custom commands you write yourself that are specific to your apps.
You could use django logging handler AdminEmailHandler:
https://docs.djangoproject.com/en/dev/topics/logging/#django.utils.log.AdminEmailHandler
As the docs say:
This handler sends an email to the site admins for each log message it receives.
So you could use this to log an error on any exception raised in the management command, and the exception would be automatically send to the admins
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With