Reverse for 'password_reset_done' not found. 'password_reset_done' is not a valid view function or pattern name.

I am setting up a password set feature using gmail host for my app and received above error message.
Below is my SMTP config:

EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "smtp.gmail.com"
EMAIL_PORT = 587
EMAIL_USE_TLS = True

I have provided my gmail account and app passkey.

Below is my app’s urls.py and loginuser.html:
core/urls.py

    path(
        "password_reset/", auth_views.PasswordResetView.as_view(), name="password_reset"
    ),
    path(
        "password_reset_done/",
        auth_views.PasswordResetDoneView.as_view(),
        name="password_reset_done",
    ),
    path(
        "reset/<uidb64>/<token>/",
        auth_views.PasswordResetConfirmView.as_view(),
        name="password_reset_confirm",
    ),
    path(
        "password_reset_complete/",
        auth_views.PasswordResetCompleteView.as_view(),
        name="password_reset_complete",
    ),
    <div class="text-center">
      <a href="{% url 'core:signupuser' %}?next={{ request.GET.next }}">&marker;Create an account?</a>&middot;&middot;&middot;&middot;&middot;&middot;
      <a href="{% url 'core:password_reset' %}">&marker;Forget password?</a>
    </div>

The error message appeared when i clicked on ‘Reset my password’ after entering a valid emaill address.

Appreciate someone can advise me on how to resolve my problem.

Thank you in advance.

What view and/or template is trying to reverse password_reset_done? That is the view and template we need to see.

Hi Ken,

Thank you for your response and I’ve to confess that I’m new to Django so pardon me for my show of ignorance…

I was of the impression that my code is using the built-in views and templates which I have imported from django.contrib.auth. If my assumption is right, I am using the PasswordResestDoneView and the dynamic link to the template is ‘password_reset_done’.

Please let me know if I’m wrong and how to resolve the issues.

I have tested my gmail SMTP setting and app passkey to confirm that it is working fine. I received an output ‘1’ when I sent below code on Shell:

from django.core.mail import send_mail
send_mail(‘Django mail’, ‘This e-mail was sent with Django.’, ‘alvinwong7896@gmail.com’, [‘alvinwong7896@gmail.com’], fail_silently=False)

Hope I have provided the info you need and thank you again.

Alvin

Ok, first a side note: This error has nothing to do with actually sending emails. The error is either in a view, template, or URL definition.

It reads to me like your urls that you list above are not in your root urls.py file, that they’re in an app named “core”. Please post the complete core/urls.py file. Also post your root urls.py file showing how you’re including these urls.

Side note: When posting code here, enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted. (I’ve taken the liberty of fixing your original post for you.)

Hi Ken,

Below is the project(root) urls and core/urls

project/urls.py:

from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, include


urlpatterns = [
    path("admin/", admin.site.urls),
    path("", include("core.urls", namespace="core")),
    path("inbox/", include("conversation.urls", namespace="conversations")),
    path("dashboard/", include("dashboard.urls")),
    path("items/", include("item.urls", namespace="items")),
    path("location/", include("location.urls", namespace="location")),
    path("blog/", include("blog.urls", namespace="blog")),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

core/urls.py:

from django.contrib.auth import views as auth_views
from django.urls import path

from . import views
from .forms import LoginForm

app_name = "core"

urlpatterns = [
    path("", views.home, name="home"),
    path("contact/", views.contact, name="contact"),
    path("signupuser/", views.signupuser, name="signupuser"),
    path("loginuser/", views.loginuser, name="loginuser"),
    path("logoutuser/", views.logoutuser, name="logoutuser"),
    path(
        "reset_password/", auth_views.PasswordResetView.as_view(), name="reset_password"
    ),
    path(
        "reset_password_sent/",
        auth_views.PasswordResetDoneView.as_view(),
        name="password_reset_done",
    ),
    path(
        "reset/<uidb64>/<token>/",
        auth_views.PasswordResetConfirmView.as_view(),
        name="password_reset_confirm",
    ),
    path(
        "reset_password_complete/",
        auth_views.PasswordResetCompleteView.as_view(),
        name="password_reset_complete",
    ),
]

Thank you and kind regards,

Alvin

So this:

defines a namespace for these URLs.

That means you need to reference these URLs specifying that namespace.

In this case, then it would be core:password_reset_done.

You either need to update/override the template being used, or move these password-related urls outside the context of your app. (I recommend the latter)