Python Forum
django - add l<a> tag - render_to_string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
django - add l<a> tag - render_to_string
#1
Hi,

i have the follwoing code in view.py:
            subject = "Thank you for your payment!"
			template = render_to_string('cart/email_template2.html', {'name': request.user.first_name, 
				'transaction_id' : transaction_id, 'total':total, 'items': items})

			to = request.user.email
			res = send_mail(subject , template , settings.EMAIL_HOST_USER, [to], fail_silently=True)
email_template2.html:
Dear {{name}},

  Thank you for making your payment towards:

  Your Transaction ID is {{transaction_id}}
  Total Amount Paid is {{total}} AED
	

  It’s been a pleasure doing business with you and below you will see the links to download your
  purchased items.

  {% for i in items %}
    
        <a href="l{{ i }}"></a>
    
  {% endfor %}
  Best wishes,
and this is what i get:

Quote: It’s been a pleasure doing business with you and below you will see the links to download your
purchased items.


<a href="localhost:8000/cart/images/shirt_xKIUpLA.jpg"></a>
<a href="localhost:8000/cart/images/watch_PtBG10p.jpg"></a>

"i" are the links for the items to be downloaded but they are presented as text not links. How to add a link? I tried to add <a> tag but in the email it stays that way.

Thanks...
Reply
#2
Use the html_message parameter of send_mail
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,247 Jun-30-2019, 12:21 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020