2

I send a html email to the users using the EmailMultiAlternatives and it worked, but the problem is in the email message the link is not working.

But when I tried doing <a href="http://127.0.0.1{% url 'add_your_details' user.username %}"> then it worked perfectly as I wanted.

template

<a href="{{ request.scheme }}://{{ request.get_host }}{% url 'add_your_details' user.username %}" 
target="_blank">Add your details </a>

settings

ALLOWED_HOSTS = ['127.0.0.1']
Hello
  • 312
  • 1
  • 5
  • 14
  • Please Checkout this question https://stackoverflow.com/questions/1451138/how-can-i-get-the-domain-name-of-my-site-within-a-django-template – rajuniit Sep 13 '19 at 18:27

1 Answers1

0

I solved this by using the get_current_site method.

In views:

from django.contrib.sites.shortcuts import get_current_site

my_current_domain = get_current_site(request)
return {'domain':my_current_domain}

then in template

<a href="{{ request.scheme }}://{{ domain }}{% url 'add_your_details' user.username %}" 
target="_blank">Add your details </a>
Hello
  • 312
  • 1
  • 5
  • 14