Django rest-auth密码重置不起作用

时间:2017-07-21 03:01:56

标签: django django-rest-framework django-rest-auth

我使用Django为移动应用程序构建RESTful API,我使用django rest-auth库进行身份验证,但是当我尝试使用密码重置时出现以下错误:

NoReverseMatch at /auth/password/reset/
Reverse for 'auth_password_reset_confirm' with arguments '(b'OQ', '4nx-
6653c24101b5443f726b')' and keyword arguments '{}' not found. 0 pattern(s) 
tried: []

从我的网址模式中获取此片段

url(r'^', include('django.contrib.auth.urls')),
url(r'^auth/', include('rest_auth.urls')),
url(r'^auth/registration/', include('rest_auth.registration.urls')),

我尝试了这里提到的一些解决方案(在代码片段中添加第一个模式)但仍然有相同的错误。

3 个答案:

答案 0 :(得分:1)

您没有定义该网址,您可以从rest-auth库检查演示项目,看看它如何处理网址(和相关模板)。

https://github.com/Tivix/django-rest-auth/blob/master/demo/demo/urls.py

答案 1 :(得分:1)

试试这个: 在 Settings.py 中:确保“app”位于已安装应用的末尾

然后再试一次

答案 2 :(得分:0)

此错误表示您尚未使用此名称auth_password_reset_confirm定义任何网址,因此您需要创建一个名为auth_password_reset_confirm的网址。

您需要以这种方式自定义django rest-auth

  

在rest-auth> urls.py

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

在这种情况下,请将name设为auth_password_reset_confirm。在我的情况下,我为此反向网址password_reset_confirm收到此错误,因此我将其作为网址中的名称。

但在您的情况下,它将是auth_password_reset_confirm

相关问题