Creating email templates with Django

From the docs, to send HTML e-mail you want to use alternative content-types, like this: from django.core.mail import EmailMultiAlternatives subject, from_email, to = ‘hello’, ‘[email protected]’, ‘[email protected]’ text_content=”This is an important message.” html_content=”<p>This is an <strong>important</strong> message.</p>” msg = EmailMultiAlternatives(subject, text_content, from_email, [to]) msg.attach_alternative(html_content, “text/html”) msg.send() You’ll probably want two templates for your e-mail – a … Read more

RuntimeWarning: DateTimeField received a naive datetime

The problem is not in Django settings, but in the date passed to the model. Here’s how a timezone-aware object looks like: >>> from django.utils import timezone >>> import pytz >>> timezone.now() datetime.datetime(2013, 11, 20, 20, 8, 7, 127325, tzinfo=pytz.UTC) And here’s a naive object: >>> from datetime import datetime >>> datetime.now() datetime.datetime(2013, 11, 20, … Read more