When using django mailer (https://github.com/pinax/django-mailer) I realized that the default tables added to the admin area (such as Message logs and Messages) did not add the message_log field which indeed is available if one looks at the tables that are added.
Since the error message is very valuable to me I wanted to add it, and simply added the "log_message" to the app's MessageLogAdmin like this:
class MessageLogAdmin(MessageAdminMixin, admin.ModelAdmin):
list_display = ["id", show_to, "subject", "message_id", "when_attempted", "result", "log_message"]
list_filter = ["result"]
date_hierarchy = "when_attempted"
readonly_fields = ['plain_text_body', 'message_id']
search_fields = ['message_id']
However, is there really no other way to customize the admin area for django-mailer other than modifying the source code? E.g through settings.py
No you can't do that via settings.py
If I understand correctly, you don't want to fork the app just to edit admin.py
, but rather keep it in the requirements.txt
file. In that case you could do something like:
class MyOwnMessageLogAdmin(MessageAdminMixin, admin.ModelAdmin):
list_display = ["id", show_to, "subject", "message_id", "when_attempted", "result", "log_message"]
list_filter = ["result"]
date_hierarchy = "when_attempted"
readonly_fields = ['plain_text_body', 'message_id']
search_fields = ['message_id']
admin.site.unregister(MessageLog)
admin.site.register(MessageLog, MyOwnMessageLogAdmin)