django.contrib.auth.urls Reverse for 'password_change_done' not found

Hello i am new programming in django, i am trying to use django.contrib.auth.urls for user login/logout/change_password functionalities.

I have coded login/logout without problems but change password functinality seems not to work correctly, it changes user password but doesnt redirect me to password_change_done template, it tries but the url isnt found:

Reverse for 'password_change_done' not found. 'password_change_done' is not a valid view function or pattern name.
Request Method:	POST
Request URL:
Django Version:	3.1.4
Exception Type:	NoReverseMatch
Exception Value:	
Reverse for 'password_change_done' not found. 'password_change_done' is not a valid view function or pattern name.
Exception Location:	/usr/home/kr0m/supercoolEnv/lib/python3.7/site-packages/django/urls/, line 685, in _reverse_with_prefix
Python Executable:	/usr/home/kr0m/supercoolEnv/bin/python
Python Version:	3.7.9
Python Path:	
Server time:	Tue, 15 Dec 2020 08:21:36 +0100

I have configured urls in the following way inside my app:

from django.urls import path, include
from . import views

app_name = 'supercoolApp'
urlpatterns = [
    path('', views.index, name='index'),
    path('sign_up/', views.sign_up, name='sign_up'),
    path('accounts/', include('django.contrib.auth.urls')),
    path('show_routine/', views.show_routine, name='show_routine'),
    path('generate_auto_routine/', views.generate_auto_routine, name='generate_auto_routine'),
    path('save_auto_routine/>', views.save_auto_routine, name='save_auto_routine'),
    path('generate_custom_routine/', views.generate_custom_routine, name='generate_custom_routine'),
    path('save_custom_routine/>', views.save_custom_routine, name='save_custom_routine'),
    path('edit_routine/', views.edit_routine, name='edit_routine'),
    path('update_routine/', views.update_routine, name='update_routine'),
    path('delete_routine/', views.delete_routine, name='delete_routine'),

My project urls:

from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path('', include('supercoolApp.urls')),

And i can see in django.contrib.auth.urls the correct urls:
cat /usr/home/kr0m/supercoolEnv/lib/python3.7/site-packages/django/contrib/auth/

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

urlpatterns = [
    path('login/', views.LoginView.as_view(), name='login'),
    path('logout/', views.LogoutView.as_view(), name='logout'),

    path('password_change/', views.PasswordChangeView.as_view(), name='password_change'),
    path('password_change/done/', views.PasswordChangeDoneView.as_view(), name='password_change_done'),

    path('password_reset/', views.PasswordResetView.as_view(), name='password_reset'),
    path('password_reset/done/', views.PasswordResetDoneView.as_view(), name='password_reset_done'),
    path('reset/<uidb64>/<token>/', views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
    path('reset/done/', views.PasswordResetCompleteView.as_view(), name='password_reset_complete'),

I tested that the url is found correctly from my testing template and i am redirected to password_change_done template:

<a class="dropdown-item" href={% url 'supercoolApp:password_change_done'%}>done</a>

The problem seems to be that password_change is not able to see password_change_done url, any idea of what i am doing wrong?

The trouble is that you’ve nested the auth.urls inside of the supercoolApp namespace. The default password change functionality will attempt to generate the url with the name password_change_done, not supercoolApp:password_change_done. There are a number of options, but two are to either move the auth urls out of supercoolApp or modify the templates/views such that it uses the correct url.

It’s also possible to change some of the properties on the default django classes (example) to route to the correct urls.

You can find more of the details and possibilities by reviewing the documentation on the authentication system.

Ok, i will try to move the auth outside supercoolApp.

Thank you for your time.

try this:

path(‘password_change/’, views.PasswordChangeView.as_view(success_url=‘done’), name=‘password_change’),