当我使用' ResetMyPassword'时,我收到以下错误按钮
Reverse for 'password_reset_confirm' with arguments '()' and keyword arguments '{'uidb64': b'MTI', 'token': '48i-a406f922c705599d2c1e'}' not found. 1 pattern(s) tried: ['blog/resetpassword/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>,+)/$']
请在下面找到我的urls.py
from django.conf.urls import url, patterns
from django.contrib.auth.views import *
from . import views
urlpatterns = [
url(r'^home$', views.home, name = 'blog_home'),
url(r'^newpost$', views.new_post, name = 'blog_new_post'),
url(r'^login$', views.login_user, name = 'blog_login'),
url(r'^logout$', views.logout_user, name = 'blog_logout'),
url(r'^register$', views.register_user, name = 'blog_register'),
url(r'^resetpassword/passwordsent/$', password_reset_done, name = 'password_reset_done'),
url(r'^resetpassword/$', password_reset, name = 'password_reset'),
url(r'^resetpassword/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>,+)/$', password_reset_confirm, name = 'password_reset_confirm'),
url(r'^reset/done/$', password_reset_complete, name = 'password_reset_complete'),
答案 0 :(得分:2)
您的password_reset_confirm
网址格式已过期。它从uidb36变为uidb64 in Django 1.6。它应该是:
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
'django.contrib.auth.views.password_reset_confirm',
name='password_reset_confirm'),
同时更新密码重置电子邮件模板:
{% url 'password_reset_confirm' uidb64=uid token=token %}
在Django 1.8+中,您应该使用网址模式中的视图而不是字符串。
from django.contrib.auth.views import password_reset_confirm
urlpatterns = [
...
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
password_reset_confirm, name='password_reset_confirm'),
...
]
确保你