首页 > 解决方案 > django-rest-auth password reset sending wrong domain in email

问题描述

I'm trying to test my password reset configuration on my localhost using django-rest-auth. The email verification and registration work, and I can trigger a password reset event and send an email, but the email contains the wrong domain. Right now it is passing a link containing my-site.com as the domain instead of 0.0.0.0:8000 as the domain. I am running the app inside a docker container which is why it is 0.0.0.0:8000 instead of 127.0.0.1:8000.

Current result:

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

Expected result

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

My url file for my registration is:

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')),
]

I ran across another post that suggested changing the site id, but I'm not sure this is correct.

How do I get it to pass the currently served domain instead of the site id domain?

标签: djangodjango-rest-frameworkdjango-allauthdjango-rest-auth

解决方案


简单的解决方案

第 1 步:转到/admin/sites/site/,您会看到类似下面的内容, 第 2 步:使用以下值编辑现有条目,然后将其保存 域名:0.0.0.0 :8000 显示名称:您的站点名称在此处输入图像描述




在此处输入图像描述


推荐阅读