Big Problem After Going Live: NoReverseMatch at /login/ Reverse for 'password_reset' not found. 'password_reset' is not a valid view function or pattern name

1,381 views
Skip to first unread message

Dave Ko

unread,
Jan 31, 2020, 8:35:44 PM1/31/20
to Django users
Hi everyone,

I am pretty new to django programming, I was following a tutorial and try to set up a blog,
everything seems to fine on my localhost machine, but after deployment and fixing some bugs,
I run into a problem which I have no idea what to do even with hours of search on stackoverflow.

So, here is my problem, I have made a login page, register page.
After deployment there is not other users besides admin,
but after register, when i try to login, it goes to error page you can see over here roasitas.com/login/

Screenshot 2020-02-01 at 9.27.48 AM.png


here is my urls.py 

I really want finish this blog and keep building it please help me out, thanks in advance!


from django.conf.urls.static import static
from rest_framework import routers, serializers, viewsets
from users import views as users_view
from django.contrib.auth import views as auth_views
from news import views as news_views
from news.models import Writer, News
from news.serializers import UserSerializer, NewsSerializer

urlpatterns = [
   path('',include('news.urls', namespace="news")),
   path('admin/', admin.site.urls),
   path('register/', users_view.register, name='register'),
   path('profile/', users_view.profile, name='profile'),
   path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'),
   path('logout/', auth_views.LogoutView.as_view(template_name='users/logout.html'), name='logout'),
   path('password-reset/',
        auth_views.PasswordResetView.as_view(
           template_name='users/password_reset.html',
           subject_template_name='users/password_reset_subject.txt',
           success_url=reverse_lazy('users:password_reset_done')
        ),
        name='password_reset'),

    path('password-reset/done/',
        auth_views.PasswordResetDoneView.as_view(
            template_name='users/password_reset_done.html'
        ),
        name='password_reset_done'),

    path('password-reset-confirm/<uidb64>/<token>/',
   auth_views.PasswordResetConfirmView.as_view(
       template_name='users/password_reset_confirm.html'
       ),
   name='password_reset_confirm'),

     path('password-reset-complete/',
        auth_views.PasswordResetCompleteView.as_view(
            template_name='users/password_reset_complete.html'
        ),
        name='password_reset_complete'),

    path('api/', include(router.urls)),
   path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
   path('/tinymce/', include('tinymce.urls')),

]

if settings.DEBUG:
   urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


Kevin Dublin

unread,
Jan 31, 2020, 9:50:04 PM1/31/20
to django...@googlegroups.com
Hey, you have password_reset instead of "password-reset."

We've all been there at some point. :)

Keep up the good work,

Kevin

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/561c6b97-6428-4af2-a1dc-09af93387b77%40googlegroups.com.

Kevin Dublin

unread,
Jan 31, 2020, 9:51:27 PM1/31/20
to django...@googlegroups.com
Jk, just saw your related name. Will need a little more time and a better screen. I'm on my phone

Jorge Gimeno

unread,
Jan 31, 2020, 11:20:29 PM1/31/20
to django...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/561c6b97-6428-4af2-a1dc-09af93387b77%40googlegroups.com.

I attempted to create an account and log in, and it worked for me! Your urls don't have a path to password_reset in the url.  That's the usual culprit for that exception to be raised.

-Jorge

DC

unread,
Jan 31, 2020, 11:22:38 PM1/31/20
to django...@googlegroups.com
Oh yes because I have just commented it out for testing , let me uncomment it and see what happens

Dave Ko

unread,
Jan 31, 2020, 11:32:41 PM1/31/20
to Django users
 I also have some trouble with using signal, which works perfectly fine on localhost but not deployed
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.

Jorge Gimeno

unread,
Feb 1, 2020, 12:16:53 AM2/1/20
to django...@googlegroups.com
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/697c8672-d832-4899-998e-f6d4d6eb8779%40googlegroups.com.

By chance did you set LOGIN_REDIRECT_URL in settings.py?

-Jorge

Dave Ko

unread,
Feb 1, 2020, 12:19:30 AM2/1/20
to Django users

LOGIN_REDIRECT_URL = 'news:all_news'

On Saturday, February 1, 2020 at 12:20:29 PM UTC+8, jlgimeno71 wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.

Dave Ko

unread,
Feb 1, 2020, 12:20:53 AM2/1/20
to Django users

LOGIN_REDIRECT_URL = 'news:all_news'


all_news is the first page of the website

Jorge Gimeno

unread,
Feb 1, 2020, 1:10:01 AM2/1/20
to django...@googlegroups.com
What I believe is going on is that Django is looking for the password reset view at password_reset, and that url path doesn't exist anywhere in urls.py.  I see a path named "password-reset", which won't match.

Let's try to rename that url conf to password_reset, and leave the rest unchanged.  Does anything change?

-Jorge

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0d5c6caf-65dc-4fc3-a69c-fe25d0eef2f2%40googlegroups.com.

Jorge Gimeno

unread,
Feb 1, 2020, 1:10:58 AM2/1/20
to django...@googlegroups.com
I apologize to the list for posting all the emails to everyone.  I'll keep this going off list.


-Jorge

Dave Ko

unread,
Feb 1, 2020, 1:16:59 AM2/1/20
to Django users


Hi Jorge,
I have changed to it "password_reset" from "password-reset" 
But what i type www.roastias/password_reset/
it shows no url, but i have checked my folders so the templates/users/password_reset.html and reset of the password related urls in the folder
but not on the error page

Dave Ko

unread,
Feb 1, 2020, 1:20:56 AM2/1/20
to Django users
git: https://github.com/koloyyee/roasitas.git
link to the repository: https://github.com/koloyyee/roasitas

please have a look at the files, it is quite frustrating because everything works okay at development level,
and at product level it just break

Thanks again Jorge!
Reply all
Reply to author
Forward
0 new messages