django-mailer-2
django-mailer-2 copied to clipboard
send_mail fails with KeyError: 1 under Django >=1.8.3
The Django 1.8.3 security update introduces a backport (django/django@76c526f80e43b0bf5199dfe33b1ce31e813fa2fb) which casts the verbosity argument to an int.
This results in the error:
File ".../django-mailer/django_mailer/management/commands/__init__.py", line 13, in create_handler
handler.setLevel(LOGGING_LEVEL[verbosity])
KeyError: 1
In my fork I just needed to change LOGGING_LEVEL in https://github.com/SmileyChris/django-mailer-2/blob/master/django_mailer/management/commands/init.py#L4 from:
LOGGING_LEVEL = {'0': logging.ERROR, '1': logging.WARNING, '2': logging.DEBUG}
to:
LOGGING_LEVEL = {0: logging.ERROR, 1: logging.WARNING, 2: logging.DEBUG}
because I don't need to maintain backwards compatibility with earlier Django versions.
A backwards compatible fix in this source repo would need either a version check to set LOGGING_LEVEL appropriately or a try-catch in create_handler to cast if there's a KeyError.