Home » Python » python – Receiving 2 password reset emails in Django everytime i try to reset a password-Exceptionshub

python – Receiving 2 password reset emails in Django everytime i try to reset a password-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment


I am a beginner in Django and i have been following an online tutorial to build a web application. I had been trying to add the password reset functionality to the application for the past few days. I set up a google app password and finally got the password reset to work. But now, every time i try to reset a password, i receive 2 password reset emails on my email account. I have reset the password successfully a few times but i continue to receive two emails every time i try to reset a password. I tried to look for answers online but couldn’t find anything. I have also cross-checked my code with the tutorial. Here are some code snippets that might be relevant:

Project settings.py:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = os.environ.get('EMAIL_USER')

Project urls.py:

from django.contrib import admin
from django.urls import path, include
from users import views as user_views
from django.contrib.auth import views as auth_views
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
        path('admin/', admin.site.urls),
        path('register/', user_views.register, name='register'),
        path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'),
        path('logout/', auth_views.LogoutView.as_view(template_name='users/logout.html'), name='logout'),
        path('password-reset/', auth_views.PasswordResetView.as_view(template_name='users/password_reset.html'),
        path('password-reset/done/', auth_views.PasswordResetDoneView.as_view(
            template_name='users/password_reset_done.html'), name='password_reset_done'),
        path('password-reset-confirm/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(
            template_name='users/password_reset_confirm.html'), name='password_reset_confirm'),
        path('password-reset-complete/', auth_views.PasswordResetCompleteView.as_view(
            template_name='users/password_reset_complete.html'), name='password_reset_complete'),
        path('profile/', user_views.profile, name='profile'),
        path('', include('blog.urls')),

Any help will be highly appreciated. Thanks!

PS: This is my first question on StackOverflow. Please let me know if i can improve it in any way.

How to&Answers: