2014-11-06 82 views
-1

我試着在更改Django中的密碼時應用this method,但在我的情況下不起作用。NoReverseMatch在/更改密碼/

這裏的回溯:

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

您的觀點是什麼樣子?另外,你訪問了什麼網址? – dazedconfused 2014-11-06 06:09:26

回答

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