我缺少這裏真正基本的東西。Django反向問題()
我想重用django的更改密碼視圖。我有以下的urls.py:
(r'^change-password/$', 'profile.views.change_password', {},'change_password'),
url(r'^change-password-done/$', 'profile.views.password_change_done', name='django.contrib.auth.views.password_change_done'),
和相應的views.py:
from django.contrib.auth.views import password_change, password_change_done
def change_password(request,template_name="password_change_form.html"):
"""Change Password"""
return password_change(request,template_name=template_name)
def password_change_done(request, template_name="password_change_done.html"):
return render_to_response(template_name,(),context_instance= RequestContext(request))
,但我得到以下錯誤:
Reverse for 'django.contrib.auth.views.password_change_done' with arguments '()' and keyword arguments '{}' not found.
看了看源,看到這line:
post_change_redirect = reverse('django.contrib.auth.views.password_change_done')
如果我改變我的urls.py進入之後,我沒有得到上述錯誤:
url(r'^change-password-done/$', 'django.contrib.auth.views.password_change_done', name='anything'),
,但我很困惑,逆()應該查找使用「名」參數?我在這裏錯過了什麼?
我使用Django 1.2.3
這正是我無法理解的文檔中的一部分。當我做'reverse('django.contrib.auth.views.password_change_done')'時,它應該回退到尋找名稱關鍵字參數,當我有'url(r'^ change-password-done/$' 'profile.views.password_change_done',name ='django.contrib.auth.views.password_change_done'), ' – 2011-03-27 09:58:14