Django没有Django.contrib.auth.views.password的反向设置\u reset\u confirm
我正在尝试使用Django的内置身份验证视图进行密码重置,但是我不明白为什么应用程序在内置身份验证视图Django没有Django.contrib.auth.views.password的反向设置\u reset\u confirm,django,django-authentication,Django,Django Authentication,我正在尝试使用Django的内置身份验证视图进行密码重置,但是我不明白为什么应用程序在内置身份验证视图password\u reset\u confirm中出错。你知道我如何解决这个问题,或者至少调试它吗?我已经在这个问题上纠缠了一段时间了 模板错误 NoReverseMatch at /accounts/password/reset/ Reverse for 'django.contrib.auth.views.password_reset_confirm' with arguments '
password\u reset\u confirm
中出错。你知道我如何解决这个问题,或者至少调试它吗?我已经在这个问题上纠缠了一段时间了
模板错误
NoReverseMatch at /accounts/password/reset/
Reverse for 'django.contrib.auth.views.password_reset_confirm' with arguments '()' and keyword arguments '{u'uidb64': u'xxxxxxxxxxxxxxxxxxxxxxx', u'token': u'xxxxxxxxxxxxxxxxx'}' not found.
Error during template rendering
In template /home/user/Envs/local/lib/python2.7/site-packages/django/contrib/admin/templates/registration/password_reset_email.html, error at line 6
Reverse for 'django.contrib.auth.views.password_reset_confirm' with arguments '()' and keyword arguments '{u'uidb64': u'xxxxxxxxxxxxxxxxxxxxxxx', u'token': u'xxxxxxxxxxxxxxxx'}' not found.
----> {{ protocol }}://{{ domain }}{% url 'django.contrib.auth.views.password_reset_confirm' uidb64=uid token=token %} <---- Template errors here
我相信,既然您已经为URL映射指定了一个名称,那么您可以在以下列表中使用该名称:
{% url 'password_reset_confirm' uid token %}
假设uid
和token
在上下文中
您可能可以按照自己喜欢的方式进行:
urlpatterns = patterns(
'django.contrib.auth.views',
(r'^password/reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$', 'password_reset_confirm'),
)
或者,如果您确实想保留应用程序的前缀,只需单独添加模式:
from django.contrib.auth.views import login, password_reset, password_reset_confirm, password_reset_done, password_reset_complete
urlpatterns = patterns('',
url(r'^password/reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$','django.contrib.auth.views.password_reset_confirm'),
)
urlpatterns += patterns('userProfile.views',
...userProfile_urls_here...
)
从django.contrib.auth.views导入登录、密码重置、密码重置确认、密码重置完成、密码重置完成
urlpatterns=模式(“”,
url(r“^password/reset/(?P[0-9A-Za-z\-]+)/(?P.+)/$”,“django.contrib.auth.views.password\u reset\u confirm”),
)
urlpatterns+=模式('userProfile.views',
…用户配置文件\u URL\u此处。。。
)
这两种解决方案中的任何一种都应该允许您反转整个内置视图
文档链接:
请在列表中显示相关代码template@Joseph它由
--->
符号表示。具体来说,这一部分:{%url'django.contrib.auth.views.password\u reset\u confirm'uidb64=uid token=token%}
。url.py
驻留在什么应用程序中?你能简单地尝试一下吗?{%url'password\u reset\u confirm'uid token%}
?我会尝试一件事:使用相同的url模式:是的,我按照你的建议,看我的编辑。你知道为什么我不能反转内置的auth视图吗?请看我的附加更新,我相信这就解释了。不能让内置的反转工作来拯救我的生命。我猜,我不得不忍受模板黑客。真烦人!我甚至尝试传递当前应用程序
参数,但没有结果。
urlpatterns = patterns(
'django.contrib.auth.views',
(r'^password/reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$', 'password_reset_confirm'),
)
from django.contrib.auth.views import login, password_reset, password_reset_confirm, password_reset_done, password_reset_complete
urlpatterns = patterns('',
url(r'^password/reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$','django.contrib.auth.views.password_reset_confirm'),
url(r'...other_app_urls_here','other_view'),
...)
from django.contrib.auth.views import login, password_reset, password_reset_confirm, password_reset_done, password_reset_complete
urlpatterns = patterns('',
url(r'^password/reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$','django.contrib.auth.views.password_reset_confirm'),
)
urlpatterns += patterns('userProfile.views',
...userProfile_urls_here...
)