Opened 3 weeks ago

Last modified 6 days ago

#36138 assigned New feature

Simplify ADMINS and MANAGERS email list settings

Reported by: Mike Edmunds Owned by: Mike Edmunds
Component: Core (Mail) Version: 5.1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Mike Edmunds)

Django should allow the ADMINS and MANAGERS settings to be simple lists of email addresses, like this:

# Doesn't work in Django through 5.2:
ADMINS = ["john@example.com", "mary@example.com"]

Right now, those settings both expect a list of tuples of (full name, email address). But the name part is ignored in both mail_admins() and mail_managers()—and it's been ignored for at least 20 years (as far back as the Git history goes):

ADMINS = [("name is ignored", "john@example.com"), ("ignored", "mary@example.com)]

#30604 added an error on detecting the (reasonable) mistake of trying to set ADMINS or MANAGERS to a simple list of addresses as in first example.

This ticket proposes instead allowing—and documenting—simple address lists in these settings. For compatibility during a standard deprecation period, Django would also continue to support the list-of-tuples form (with the name field ignored). After deprecation, tuples would raise an error. [Edits: deprecated tuples, based on forum discussion.]

Incidentally, if you do want to include a display-name in the admins/managers recipients lists, that can be done with the RFC 5322 "name" <addr> format (which is accepted by all the django.core.mail APIs):

# Works in Django 5.2 and earlier:
ADMINS = [
    ("ignored", "John <john@example.com>"), 
    ("ignored", '"Mary, IT (Ops)" <mary@example.com>'),
]

# Also allowed after this proposed change:
ADMINS = [
    "John <john@example.com>", 
    '"Mary, IT (Ops)" <mary@example.com>',
]

Change History (8)

comment:1 by Sarah Boyce, 2 weeks ago

Resolution: wontfix
Status: newclosed

Thank you for the ticket!

I think this is a good suggestion, however can you raise this on the Django forum first as I want to check the community appetite on:

  • should we deprecate the tuple? I understand that's a change to almost every project but not a particularly difficult change (django-upgrade could automate this for example).
  • if we don't deprecate it, we have two ways of doing this. Are we comfortable with that?

I'll close the ticket for now, but if we have agreement whether to deprecate or not, please return to this ticket and reference the forum discussion so we can re-open it. For more information, please refer to the documented guidelines for requesting features.

comment:3 by Mike Edmunds, 12 days ago

Description: modified (diff)
Resolution: wontfix
Status: closednew

Reopened, deprecating the tuples, based on forum feedback.

comment:4 by Mike Edmunds, 10 days ago

Owner: set to Mike Edmunds
Status: newassigned

comment:5 by Sarah Boyce, 9 days ago

Triage Stage: UnreviewedAccepted

Thank you for getting feedback

comment:6 by Mike Edmunds, 7 days ago

Has patch: set

comment:7 by Mike Edmunds, 7 days ago

Patch needs improvement: set

comment:8 by Mike Edmunds, 6 days ago

Patch needs improvement: unset
Note: See TracTickets for help on using tickets.
Back to Top