title: Sending HTML email in django
body: <p>In my project I've added a newsletter feed. But when trying to send emails with this function :</p>
  
  <pre><code>def send(request):
      template_html = 'static/newsletter.html'
      template_text = 'static/newsletter.txt'
      newsletters = Newsletter.objects.filter(sent=False)
      subject = _(u"Newsletter")
      adr = NewsletterEmails.objects.all()
      for a in adr:
          for n in newsletters:
              to = a.email
              from_email = settings.DEFAULT_FROM_EMAIL           
              subject = _(u"Newsletter Fandrive")
              text = get_template(template_text)
              html = get_template(template_html)
              d = { 'n': n,'email': to }
              text_content = text.render(d)
              html_content = html.render(d)
  
              msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
              msg.attach_alternative(html_content, "text/html")
              msg.send()
  </code></pre>
  
  <p>using those templates :</p>
  
  <pre><code>//text
  
  ===================  Newsletter - {{ n.date }}  ============
  ==========================================================
                        {{ n.title }}
  ==========================================================          
  {{ n.text }}
  ==========================================================
  
  //html
  
  &lt;html&gt;
      &lt;head&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;div style=""&gt;
          &lt;div style=""&gt;
              &lt;h1 style=""&gt;{{ n.title }} - {{n.date}}&lt;/h1&gt;
                  &lt;p style=""&gt;            
                      {{ n.text }}
                  &lt;/p&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and models :</p>
  
  <pre><code>class Newsletter(models.Model):
      title = models.CharField("title", blank=False, max_length=50)
      text = models.TextField("text", blank=False)
      sent = models.BooleanField("sent", default=False)
      data = models.DateTimeField("creation date", auto_now_add=True, blank=False)
  
  class NewsletterEmails(models.Model):
      email = models.EmailField(_(u"e-mail address"),)
  </code></pre>
  
  <p>I'm getting :</p>
  
  <p><code>TemplateSyntaxError at /utils/newsletter_send/<br>
  Caught an exception while rendering: 'dict' object has no attribute 'autoescape'</code> </p>
  
  <p>in <strong>{{ n.date }}</strong> within text_email template</p>
  
  <p>Although my debug shows I'm sending proper newsletter objects to the template ,as well as debug context :</p>
  
  <p><code>context {'email': u'admin@domain.com', 'n': &lt;Newsletter: Newsletter object&gt;}</code></p>
  
  <p>Why is that happening ? From what I've found about this error it is somehow connected to sending empty dictionary to template renderer, but mine's not empty...</p>