开发者

How come I can't implement Django's forget password feature?

开发者 https://www.devze.com 2023-02-07 09:38 出处:网络
Reverse for \'django.contrib.auth.views.password_reset_confirm\' with arguments \'()\' and keyword arguments \'{\'uidb36\': \'1\', \'token\': \'2u6-e139d87034d52a80c572\'}\' not found.
Reverse for 'django.contrib.auth.views.password_reset_confirm' with arguments '()' and keyword arguments '{'uidb36': '1', 'token': '2u6-e139d87034d52a80c572'}' not found.

I already did this correctly:

(r'^password/reset/?$',password_reset ),
(r'^password/reset/don开发者_运维问答e/?$',password_reset_done ),
(r'^password/reset/confirm/?$',password_reset_confirm ),
(r'^password/reset/complete/?$',password_reset_complete),


Django is passing arguments itself; you need to accept them and pass them to the reset form.

To be really clear about what the error message is saying, it is expecting a url for the view, 'django.contrib.auth.views.password_reset_confirm', and that url MUST accept the arguments provided, in this case 'uidb36' and 'token'. If it does not, it just keeps looking until it gets to the end of your urls and then throws this error.

Something like the following should work:

(r'^password/reset/confirm/(?P<uidb36>\d+)/(?P<token>[\d\w-]+)$',password_reset_confirm ),

Personally, I'd kind of prefer if those were passed in a GET rather than the URL, but whatever :).


You're passing it arguments. None of those urlconf entries take arguments. Either drop them from the reverse or add them to the urlconf.


It is possible that you have a templatetag of this kind in a template file

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

try to search for something like that shell example:

find . -iname "*.html" -exec grep -iH "django.contrib.auth.views.password_reset_confirm" {} \;

If you find some then check that no arguments are "passed"

0

精彩评论

暂无评论...
验证码 换一张
取 消