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, sender or settings.DEFAULT_FROM_EMAIL,
recipients, bcc=bcc) recipients, bcc=bcc)
msg.attach_alternative(html_part, "text/html") msg.attach_alternative(html_part, "text/html")
for filename, filefield in files: if files:
if six.PY3: for filename, filefield in files:
msg.attach_file(filefield.path) if six.PY3:
else: msg.attach_file(filefield.path)
with open(filefield.path, 'rb') as attachedfile: else:
msg.attach(filename, attachedfile.read()) with open(filefield.path, 'rb') as attachedfile:
msg.attach(filename, attachedfile.read())
return msg.send(fail_silently) return msg.send(fail_silently)