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

时间:2019-04-10 22:42:32

标签: django django-rest-framework django-allauth django-rest-auth

我正在尝试使用django-rest-auth在本地主机上测试密码重置配置。电子邮件验证和注册工作正常,我可以触发密码重置事件并发送电子邮件,但是电子邮件包含错误的域。目前,它正在传递包含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

我用于注册的网址文件是:

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域?

1 个答案:

答案 0 :(得分:2)

简便解决方案

步骤1:,转到 /admin/sites/site/ ,您会看到类似以下内容, enter image description here

步骤2:使用以下值编辑现有条目然后保存
域名: 0.0.0.0:8000
显示名称:您的网站名称
enter image description here