Just another NoReverseMatch at /accounts/password/reset/ question. I have tried so many different solutions and nothing is working for me. BTW I get no error if I try a random password that is not in the DB.
只需另一个NoReverseMatch at / accounts / password / reset / question。我尝试了很多不同的解决方案,没有什么对我有用。顺便说一句,如果我尝试一个不在数据库中的随机密码,我没有错误。
Django 1.6
Error
NoReverseMatch at /accounts/password/reset/
Reverse for 'django.contrib.auth.views.password_reset_confirm' with arguments '()' and keyword arguments '{u'uidb64': 'Mg', u'token': u'3vb-60fc793f1a685844bbe1'}' not found. 0 pattern(s) tried: []
Error during template rendering
In template /home/jr/Documents/python/amapp1/local/lib/python2.7/site-packages/django/contrib/admin/templates/registration/password_reset_email.html, error at line 7
Reverse for 'django.contrib.auth.views.password_reset_confirm' with arguments '()' and keyword arguments '{u'uidb64': 'Mg', u'token': u'3vb-60fc793f1a685844bbe1'}' not found. 0 pattern(s) tried: []
urls.py
from django.conf.urls import patterns, url
from django.contrib.auth.views import login, password_reset, password_reset_confirm, password_reset_done, password_reset_complete
url(r'^password/reset/$', 'django.contrib.auth.views.password_reset',
{'post_reset_redirect' : '/accounts/password/reset/done/'}),
url(r'^password/reset/done/$', 'django.contrib.auth.views.password_reset_done'),
url(r'^password/reset/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm',
{'post_reset_redirect' : '/accounts/password/done/'}),
url(r'^password/done/$', 'django.contrib.auth.views.password_reset_complete'),
password_reset_email.html
{{ protocol}}://{{ domain }}{% url 'django.contrib.auth.views.password_reset_confirm' uidb64=uid token=token %}
It is the link inside the password_reset_email.html template as I do receive the email and get no error if I remove the link.
这是password_reset_email.html模板中的链接,因为我收到了电子邮件,如果删除链接则不会出错。
2 个解决方案
#1
2
Change the url in your password_reset_email.html to:
将password_reset_email.html中的网址更改为:
{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}
This is how it is done in the docs
这是在文档中完成的
#2
0
If you are using Django 1.6 as you are stating than the code you are using is wrong as password reset was changed in Django 1.6.
如果您正在使用Django 1.6,因为您使用的代码错误,因为Django 1.6中的密码重置已更改。
Please read here https://docs.djangoproject.com/en/1.7/topics/auth/default/#django.contrib.auth.views.password_reset
请阅读https://docs.djangoproject.com/en/1.7/topics/auth/default/#django.contrib.auth.views.password_reset
You must change the template for your password reset email accordingly.
您必须相应地更改密码重置电子邮件的模板。
You must also change the urls accordingly
您还必须相应地更改URL
You have now
你现在有
url(r'^password/reset/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm',
{'post_reset_redirect' : '/accounts/password/done/'}),
Should be something like this
应该是这样的
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
'django.contrib.auth.views.password_reset_confirm',
name='password_reset_confirm'),
#1
2
Change the url in your password_reset_email.html to:
将password_reset_email.html中的网址更改为:
{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}
This is how it is done in the docs
这是在文档中完成的
#2
0
If you are using Django 1.6 as you are stating than the code you are using is wrong as password reset was changed in Django 1.6.
如果您正在使用Django 1.6,因为您使用的代码错误,因为Django 1.6中的密码重置已更改。
Please read here https://docs.djangoproject.com/en/1.7/topics/auth/default/#django.contrib.auth.views.password_reset
请阅读https://docs.djangoproject.com/en/1.7/topics/auth/default/#django.contrib.auth.views.password_reset
You must change the template for your password reset email accordingly.
您必须相应地更改密码重置电子邮件的模板。
You must also change the urls accordingly
您还必须相应地更改URL
You have now
你现在有
url(r'^password/reset/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm',
{'post_reset_redirect' : '/accounts/password/done/'}),
Should be something like this
应该是这样的
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
'django.contrib.auth.views.password_reset_confirm',
name='password_reset_confirm'),