我尝试在Django中更改密码时使用this method,但在我的情况下不起作用。
这里是追溯:
Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Python27\lib\site-packages\django\views\decorators\debug.py" in sensitive_post_parameters_wrapper
75. return view(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\utils\decorators.py" in _wrapped_view
99. response = view_func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view
22. return view_func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\contrib\auth\views.py" in password_change
257. post_change_redirect = reverse('password_change_done')
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in reverse
509. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in _reverse_with_prefix
429. (lookup_view_s, args, kwargs, len(patterns), patterns))
Exception Type: NoReverseMatch at /change-password/
Exception Value: Reverse for 'password_change_done' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
在我的urls.py
:
url(r'^change-password/', 'django.contrib.auth.views.password_change'),
url(r'^password-changed/', 'django.contrib.auth.views.password_change_done'),
答案 0 :(得分:1)
不,没关系......自己弄明白了。
以下是:
url(r'^change-password/', 'django.contrib.auth.views.password_change',
{'post_change_redirect' : '/password-changed/'}),
url(r'^password-changed/', 'django.contrib.auth.views.password_change_done'),
刚刚添加了post_change_redirect
。