if files condition restored

This commit is contained in:
Pawel M 2016-12-16 10:36:00 +01:00
parent fc0ae58420
commit 97b3444a92

View File

@ -119,13 +119,14 @@ def send_templated_mail(template_name,
sender or settings.DEFAULT_FROM_EMAIL,
recipients, bcc=bcc)
msg.attach_alternative(html_part, "text/html")
for filename, filefield in files:
if six.PY3:
msg.attach_file(filefield.path)
else:
with open(filefield.path, 'rb') as attachedfile:
msg.attach(filename, attachedfile.read())
if files:
for filename, filefield in files:
if six.PY3:
msg.attach_file(filefield.path)
else:
with open(filefield.path, 'rb') as attachedfile:
msg.attach(filename, attachedfile.read())
return msg.send(fail_silently)