How to change the subject of a Django error message?

I noticed that I changed the subject for django related error emails, is it possible to change the subject? can we change the subject for django error messages?

+5
source share
2 answers

You need to set the EMAIL_SUBJECT_PREFIX variable in the Django settings file.

https://docs.djangoproject.com/en/1.8/ref/settings/#email-subject-prefix

EMAIL_SUBJECT_PREFIX

Default: '[Django]'

Subject prefix for emails sent using django.core.mail.mail_admins or django.core.mail.mail_managers . You probably want to include a finite space.

If you don't like Django error messages and want to handle them better, check out Sentry .

+11
source

If you only need this for error messages, the best choice would be to inherit from django.utils.log.AdminEmailHandler and override the def format_subject(self, subject): method.

Please note that changing EMAIL_SUBJECT_PREFIX will affect not only emails with emails, but also all emails sent to administrators, including emails with system information or so on.

+1
source

All Articles