1

My password_reset_email.html in django-registration looks like this:

{% blocktrans %}
To reset your password, please click the following link:
{% endblocktrans %}
<body>
    <p> 
        <a href="http://{{ site.domain }}{% url 'auth_password_reset_confirm' uid token %}">
        Reset password
        </a>
    </p>
</body>
{% blocktrans %}

Django is picking up the url but not {{site.domain}}. Yet, when I have the same code in the registration process {{site.domain}} was valid. What makes the password_reset_email.html different than the registration process?

Thanks.

H C
  • 1,138
  • 4
  • 21
  • 39

1 Answers1

2

django-registration (or rather django.contrib.auth) doesn't use context processors for rendering emails. You will have to add {{ site }} to the context manually during rendering. Basically you'll have to customize django-registration's urls. Something along those line:

from django.contrib.sites.models import Site
from django.contrib.auth import views as auth_views

....
url(r'^password/reset/$', auth_views.password_reset,
    {'post_reset_redirect': reverse_lazy('auth_password_reset_done'),
     'extra_email_context': {'site': Site.objects.get_current()}},
    name='auth_password_reset'),
....                       
lehins
  • 9,642
  • 2
  • 35
  • 49