I want to allow the user to reset password when the user is signed out and cannot remember the password.
I am using the django authentication framework and have created the reset_password and password_reset_done mappers.
Issue : Though I have created the password_reset_done function I continue to get the below error. Is there a step that I missed that is causing this error? I do not know what I have done wrong.
I have posted all the code that I think is relevant to what I attempting to do.
Edit with full TraceBack:
Here is the code :
relative urls.py
from django.conf.urls import url
from . import views
from django.contrib.auth.views import login, logout, password_reset, password_reset_done
urlpatterns = [
url(r'^$', views.vedic_view, name = 'vedic_home_view'),
url(r'^login/$', login, {'template_name' : 'exist/login.html'}, name = 'login'),
url(r'^logout/$', logout, {'template_name' : 'exist/logout.html'}, name = 'logout'),
url(r'^register/$', views.register_view, name = 'register'),
url(r'^profile/$', views.view_profile, name = 'view_profile'),
url(r'^profile/edit/$', views.edit_profile, name = 'edit_profile'),
url(r'^change-password/$', views.change_password, name = 'change_password'),
url(r'^reset-password/$', password_reset, name = 'reset_password'),
url(r'^reset-password/done/$', password_reset_done, name = 'password_reset_done')
]
main urls.py
from django.conf.urls import url
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'^admin/', admin.site.urls),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
from django.conf.urls import include
from django.views.generic import RedirectView
urlpatterns += [
url(r'^exist/', include('exist.urls', namespace = 'exist')),
url(r'^$', RedirectView.as_view(url='/exist/', permanent=True)),
]
As I see, you didn't include
relative.url
in your main urls.EDIT
in relative urls
In main url:
EDIT 2
Here'sthe docs on the subject, it explains it better than me with examples.
password_reset_done
is within theexists
namespace. It looks like you are trying toreverse
the named URL without including the namespace argument somewhere. We would need to see your full traceback to see exactly where that is happening.Since you are using the built-in
auth
views, the easiest fix would probably be to move your password reset handling up to your mainurls.py
. Notice in your traceback that the built-inpassword_reset
view does this:The default implementation here is to
reverse
topassword_reset_done
without any namespace. Moving the relevant URLs up to your mainurls.py
will allow them to be accessed viareverse
without a namespace argument, making the built-in views happy.I realize what the issue is.
For the built-in reset view there is a
post_reset_redirect
variable that uses the default implementationreverse(password_reset_done)
to go to the password_reset_done view.The issue is that in my main urls.py document I created the namespace variable
namespace = exist
However I did not override the default
post_reset_redirect
implementation fromreverse(password_reset_done)
toreverse(exist:password_reset_done)
.So my current
should now look like