H C
H C

Reputation: 1200

Password reset in Django-registration can't find site.domain

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.

Upvotes: 1

Views: 310

Answers (1)

lehins
lehins

Reputation: 9767

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'),
....                       

Upvotes: 2

Related Questions