django-rest-auth 重置密码电子邮件包含 'example.com ' 域而不是 site_domain

django-rest-auth reset password email contains 'example.com ' domain instead of site_domain

我在我的项目中使用 django-rest-auth 并且想要自定义重置密码时使用的电子邮件模板。如果我使用用户电子邮件在 /rest-auth/password/reset/ 发送 POST 请求,请求有效,但我收到的电子邮件是:

邮箱:

from **webmaster@localhost** via ...


...

http://**example.com**/reset/ZGJjNjU2MjAtZjdjNy00MDdjLTkyZDctZDAwZGM2M2IzMmU4/4ys-09e6403c9784bea04986/

...

基本上我希望域 example 是项目的域,发件人电子邮件是自定义电子邮件。

我看到我可以创建一个 /templates/registration/password_reset_email.html 文件并在那里进行更改。我需要更改的行是:

{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}

注册使用 django-allauth,后者又使用 sites 框架来填充电子邮件。您应该浏览到管理站点并修改您的默认 siteid1 的那个)。

参见 post installation steps django-allauth:

Add a Site for your domain, matching settings.SITE_ID (django.contrib.sites app).