首页 > 解决方案 > 编辑在确认电子邮件 dj_rest_auth 中发送的 url

问题描述

当我注册一个新用户时,电子邮件模板中发送的确认电子邮件包含后端的 url,但我需要在 forntend 中处理它。有人知道如何编辑 jazzband 的 dj_rest_auth 电子邮件模板吗?

电子邮件模板是:

来自example.com的您好!

您收到这封电子邮件是因为用户 Pinon 提供了您的电子邮件地址来连接他们的帐户。

要确认这是正确的,请转到 http://localhost:8000/auth/registration/account-confirm-email/Nw:1kO3gI:PQDfxEOyklUYIxpjNN_011ZxGQYPJRdNomzzOFjtXA0/

来自example.com的感谢!例子.com

但我需要它是这样的:

来自example.com的您好!

您收到这封电子邮件是因为用户 Pinon 提供了您的电子邮件地址来连接他们的帐户。

要确认这是正确的,请转到 http://localhost:3000/account-confirm-email/Nw:1kO3gI:PQDfxEOyklUYIxpjNN_011ZxGQYPJRdNomzzOFjtXA0/

来自example.com的感谢!例子.com

标签: reactjsdjango-rest-framework

解决方案


好的,这个东西是由 django_allauth 包处理的。因此,您必须按照他们在 (django_allauth)文档中的建议进行操作

所以我创建了这样的目录:templates/account/email/email_confirmation_message.txt 然后将此代码添加到文件中:

{% load account %}{% user_display user as user_display %}{% load i18n %}{% autoescape off %}{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Hello from {{ site_name }}!

You're receiving this e-mail because user {{ user_display }} has given your e-mail address to register an account on {{ site_domain }}.

To confirm this is correct, <a href="http://localhost:3000/auth/account/confirm/email/{{ key }}" target="_blank">Click here.</a>
{% endblocktrans %}
{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Thank you from {{ site_name }}!
{{ site_domain }}{% endblocktrans %}
{% endautoescape %}

{{ 钥匙 }}

是主要的事情要找到。


推荐阅读