0

Even after mentioning the name='password_reset_done', getting the NoReverseMatch error for 'password_reset_done'.

enter image description here

below is the urls.py file of blog application.

from django.conf.urls import url

from . import views
from django.contrib.auth.views import password_reset, password_reset_done

urlpatterns = [
url(r'^$', views.post_list, name='post_list'),
url(r'^login/$', views.user_login, name='user_login'),
url(r'^logout/$', views.user_logout, name='user_logout'),
url(r'^reset-password/$', password_reset, name='password_reset'),
url(r'^reset-password/done/$', password_reset_done, name='password_reset_done'),
url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<slug>[\w-]+)/$', views.post_detail, name='post_detail'),
url(r'^(?P<post_id>\d+)/share/$', views.post_share, name='post_share'),
url(r'^(?P<tag_slug>[\w-]+)/$', views.post_list, name='post_list_by_tag'),
]

Please help!!!

  • Where this error occurs? Inside your template? – nik_m Mar 25 '17 at 20:24
  • Possible duplicate of https://stackoverflow.com/questions/38390177/what-is-a-noreversematch-error-and-how-do-i-fix-it - particularly the remarks about including the name space in the template, given you're asking for `/blog/reset-password` and the regexp doesn't have `blog` in it – Simon Fraser Mar 25 '17 at 20:26
  • 1
    Hi Simon, I have already used as nampspace in project urls.py. urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^blog/', include('blog.urls', namespace='blog', app_name='blog')), ] – user3054319 Mar 25 '17 at 20:32
  • Yes, you've used a namespace, but the password reset views aren't expecting one. Don't put those URLs into the blog urls.py, put them into the main one - or a separate one without a namespace. – Daniel Roseman Mar 25 '17 at 22:29
  • Thanks Daniel, It worked!! – user3054319 Apr 13 '17 at 05:45

3 Answers3

1

Make following changes in main's urls.py:

urlpatterns = [
     url(r'^admin/', admin.site.urls), 
     url(r'^blog/', include('blog.urls')), 
]

Make following changes in blog's urls.py:

from django.contrib.auth import views as auth_views

urlpatterns = [
    url('^reset-password/$', auth_views.password_reset),
    url('^reset-password/done/$', auth_views.password_reset_done),
]
Ajay Singh
  • 1,251
  • 14
  • 17
0

add 'password_reset_done' name to urls.py:

from django.contrib.auth import views as auth_views

urlpatterns = [
    url('^reset-password/$', auth_views.password_reset),
    url('^reset-password/done/$', auth_views.password_reset_done, name='password_reset_done'), ]
osk386
  • 424
  • 3
  • 13
-3

NoReverseMatch at /myapp/reset-password/ Reverse for 'password_reset_done' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: [] Request Method: GET Request URL: http://127.0.0.1:8000/myapp/reset-password/ Django Version: 1.10.5 Exception Type: NoReverseMatch Exception Value:
Reverse for 'password_reset_done' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: [] Exception Location: C:\Python35-32\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 392 Python Executable: C:\Python35-32\python.exe Python Version: 3.5.3 Python Path:
['c:\Workarea\projects\Learning\dJango\mysite', 'C:\Python35-32\lib\site-packages\requests_ftp-0.3.1-py3.5.egg', 'C:\Python35-32\python35.zip', 'C:\Python35-32\DLLs', 'C:\Python35-32\lib', 'C:\Python35-32', 'C:\Python35-32\lib\site-packages'] Server time: Mon, 10 Apr 2017 10:10:32 +0000