NoReverseMatch on password_Reset_confirm

前端 未结 5 1955
梦如初夏
梦如初夏 2020-12-16 13:05

I have a problem getting password_Reset_confirm bit working.

url:

(r\'^password_reset/$\', \'django.contrib.auth.views.password_reset\'),
(r\'^passwo         


        
相关标签:
5条回答
  • 2020-12-16 13:20

    It might be a built-in view, but you still need a URL for it. You should define one in urls.py and link it up to the password_reset_confirm view.

    0 讨论(0)
  • 2020-12-16 13:28

    When using the url template tag, you need to specify the view and not the url itself. Since you are using 'django.contrib.auth.views.password_reset_confirm' in your URLConf you should use it like this:

    {% url 'django.contrib.auth.views.password_reset_confirm' ... %}
    

    More on the url template tag on Django's Built-in template tags and filters documentation.

    0 讨论(0)
  • 2020-12-16 13:28

    To pass a url to the url template tag, you can specify a name to the url in the urls.py

    url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', 
    views.password_reset_confirm, name='password_reset_confirm'),
    

    and then you can use the tag with the url name

    {% url 'password_reset_confirm' uidb64=uid token=token %}
    
    0 讨论(0)
  • 2020-12-16 13:33

    Just copy this URL to your main urls.py file, so that it recognizes the URL name

    url(r'^reset/(?P[0-9A-Za-z_-]+)/(?P[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', 'django.contrib.auth.views.password_reset_confirm', name='password_reset_confirm'),

    0 讨论(0)
  • 2020-12-16 13:35

    Be sure to have this in your urls.py:

    urlpatterns = [
        url('^', include('django.contrib.auth.urls'))
    ]
    

    See https://docs.djangoproject.com/en/1.8/topics/auth/default/#django.contrib.auth.views.password_reset Section: Authentication views

    0 讨论(0)
提交回复
热议问题