Django 邮箱验证 - 自定义邮箱 html & 404 not found accounts/profile/
Django email verification - customize email html & 404 not found accounts/profile/
我有两个问题。电子邮件验证效果很好,但我想自定义发送给用户的电子邮件。以下是邮件内容:
Hello from Localhost!
You're receiving this e-mail because user test has given yours as an
e-mail address to connect their account.
To confirm this is correct, go to
http://127.0.0.1:8000/rest-auth/registration/account-confirm-email/MTE:1h4DCn:JtkrZ1wkENQIdG8ysIVu7Qx_R44/
Thank you from Localhost! https://localhost:8000/
如何创建一个html文件并在邮件中填写我想发送的内容?电子邮件主题如何?
第二个问题是,当我点击 link 时,用户得到验证,但随后我在 /accounts/profile 上收到 404 错误。
这是我的代码:
from allauth.account.views import confirm_email
urlpatterns = [
path('accounts/', include('allauth.urls')),
path('rest-auth/', include('rest_auth.urls')),
url(r'^rest-auth/registration/account-confirm-email/(?P<key>[-:\w]+)/$', confirm_email),
path('rest-auth/registration/', include('rest_auth.registration.urls')),
]
我是否必须为 accounts/profile/ 添加 url 并创建一个显示电子邮件验证成功的 html 模板?另外,有没有办法将 url 更改为 accounts/verification-success/?
自定义电子邮件
您可以在此处找到使用的默认电子邮件模板:https://github.com/pennersr/django-allauth/tree/master/allauth/templates/account/email
- 主题:
email_confirmation_subject.txt
- 文本电子邮件:
email_confirmation_message.txt
您可以像任何其他模板一样在 Django 应用程序中覆盖它们。
要激活 HTML,您只需添加自己的名为 email_confirmation_message.html
.
的文件
您也可以在注册或确认电子邮件地址时收到不同的消息。
您可以查看 code 以了解其工作原理。
accounts/profile/
When you end up here you have successfully logged in. However, you will need to implement a view for this URL yourself, as whatever is to be displayed here is project specific. You can also decide to redirect elsewhere:
https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url
由于您必须自己实施配置文件,因此您也可以使用 accounts/verification-success/
。
我有两个问题。电子邮件验证效果很好,但我想自定义发送给用户的电子邮件。以下是邮件内容:
Hello from Localhost!
You're receiving this e-mail because user test has given yours as an e-mail address to connect their account.
To confirm this is correct, go to http://127.0.0.1:8000/rest-auth/registration/account-confirm-email/MTE:1h4DCn:JtkrZ1wkENQIdG8ysIVu7Qx_R44/
Thank you from Localhost! https://localhost:8000/
如何创建一个html文件并在邮件中填写我想发送的内容?电子邮件主题如何?
第二个问题是,当我点击 link 时,用户得到验证,但随后我在 /accounts/profile 上收到 404 错误。
这是我的代码:
from allauth.account.views import confirm_email
urlpatterns = [
path('accounts/', include('allauth.urls')),
path('rest-auth/', include('rest_auth.urls')),
url(r'^rest-auth/registration/account-confirm-email/(?P<key>[-:\w]+)/$', confirm_email),
path('rest-auth/registration/', include('rest_auth.registration.urls')),
]
我是否必须为 accounts/profile/ 添加 url 并创建一个显示电子邮件验证成功的 html 模板?另外,有没有办法将 url 更改为 accounts/verification-success/?
自定义电子邮件
您可以在此处找到使用的默认电子邮件模板:https://github.com/pennersr/django-allauth/tree/master/allauth/templates/account/email
- 主题:
email_confirmation_subject.txt
- 文本电子邮件:
email_confirmation_message.txt
您可以像任何其他模板一样在 Django 应用程序中覆盖它们。
要激活 HTML,您只需添加自己的名为 email_confirmation_message.html
.
您也可以在注册或确认电子邮件地址时收到不同的消息。
您可以查看 code 以了解其工作原理。
accounts/profile/
When you end up here you have successfully logged in. However, you will need to implement a view for this URL yourself, as whatever is to be displayed here is project specific. You can also decide to redirect elsewhere:
https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url
由于您必须自己实施配置文件,因此您也可以使用 accounts/verification-success/
。