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: http://192.168.69.9:8000/accounts/password_change/
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/resolvers.py, line 685, in _reverse_with_prefix
Python Executable: /usr/home/kr0m/supercoolEnv/bin/python
Python Version: 3.7.9
Python Path:
['/usr/home/kr0m/supercoolEnv/supercoolProject',
'/usr/local/lib/python37.zip',
'/usr/local/lib/python3.7',
'/usr/local/lib/python3.7/lib-dynload',
'/usr/home/kr0m/supercoolEnv/lib/python3.7/site-packages']
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')),
path('admin/', admin.site.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/urls.py
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?