django-rest-auth密码重置在电子邮件中发送错误的域名

问题描述 投票:0回答:1

我正在尝试使用django-rest-auth在我的localhost上测试我的密码重置配置。电子邮件验证和注册工作,我可以触发密码重置事件并发送电子邮件,但电子邮件包含错误的域。现在它传递的是包含my-site.com作为域的链接,而不是0.0.0.0:8000作为域。我在一个docker容器内运行应用程序,这就是为什么它是0.0.0.0:8000而不是127.0.0.1:8000

目前的结果:

You're receiving this email because you requested a password reset for your user account at My Site.

Please go to the following page and choose a new password:

http://my-site.com/auth/password-reset/confirm/OA/55d-7dc2614593146ac3ce82/

Your username, in case you've forgotten: testaccount

Thanks for using our site!

The My Site team

预期结果

You're receiving this email because you requested a password reset for your user account at My Site.

Please go to the following page and choose a new password:

http://0.0.0.0:8000/auth/password-reset/confirm/OA/55d-7dc2614593146ac3ce82/

Your username, in case you've forgotten: testaccount

Thanks for using our site!

The My Site team

我注册的url文件是:

from django.urls import path, include
from allauth.account.views import ConfirmEmailView
from . import views

urlpatterns = [
    path('registration/account-email-verification-sent/', views.null_view, name='account_email_verification_sent'),
    path('registration/account-confirm-email/<key>', ConfirmEmailView.as_view(), name='account_confirm_email'),
    path('registration/complete/', views.complete_view, name='account_confirm_complete'),
    path('password-reset/confirm/(<uidb64>/<token>/', views.null_view, name='password_reset_confirm'),
    path('', include('rest_auth.urls')),
    path('registration/', include('rest_auth.registration.urls')),
]

我跑过另一篇建议更改网站ID的帖子,但我不确定这是否正确。

如何让它通过当前服务的域而不是站点ID域?

django django-rest-framework django-allauth django-rest-auth
1个回答
2
投票

Easy Solution

第1步:去/admin/sites/site/,你会看到类似下面的东西,enter image description here 第2步:使用以下值编辑现有条目,然后保存 域名:0.0.0.0:8000 显示名称:您的站点名称 enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.