Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send_mail fails with KeyError: 1 under Django >=1.8.3 #26

Open
nealtodd opened this issue Jul 10, 2015 · 0 comments
Open

send_mail fails with KeyError: 1 under Django >=1.8.3 #26

nealtodd opened this issue Jul 10, 2015 · 0 comments

Comments

@nealtodd
Copy link

The Django 1.8.3 security update introduces a backport (django/django@76c526f) 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant