2009-06-02 6 views
6

Djangoに付属のパスワードリセットセットアップを使用しようとしていますが、ドキュメンテーションはあまり良くありません。私はこのようなものを持っている私のURLconfでDjango 1.0(既定のパスワードリセットを使用)

Caught an exception while rendering: Reverse for 'mysite.django.contrib.auth.views.password_reset_confirm' with arguments '()' and keyword arguments ... 

:私は、Djangoの1.0を使用していると私はこのエラーを得続ける

問題は、このファイル内にあるように見え
#django.contrib.auth.views 
urlpatterns = patterns('django.contrib.auth.views',  
    (r'^password_reset/$', 'password_reset', {'template_name': 'accounts/registration/password_reset_form.html', 'email_template_name':'accounts/registration/password_reset_email.html', 'post_reset_redirect':'accounts/login/'}), 
    (r'^password_reset/done/$', 'password_reset_done', {'template_name': 'accounts/registration/password_reset_done.html'}), 
    (r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'password_reset_confirm', {'template_name': 'accounts/registration/password_reset_confirm.html', 'post_reset_redirect':'accounts/login/', 'post_reset_redirect':'accounts/reset/done/'}), 
    (r'^reset/done/$', 'password_reset_complete', {'template_name': 'accounts/registration/password_reset_complete.html'}), 
) 

password_reset_email.html 
ライン上の
{% url django.contrib.auth.views.password_reset_confirm uidb36=uid, token=token %} 

何が起こっているのか分からないので、どんな助けもありがたいです。

おかげ

答えて

2

私が思いついた解決策を投稿したかっただけです。私は本当に100%の理由のいずれかではないので、私はちょうどハード、このようなURLをコード化

{% url django.contrib.auth.views.password_reset_confirm uidb36=uid, token=token %} 

http://mysite.com/accounts/reset/{{uid}}-{{token}}/ 
0

これは私が自分自身ではない10分前に考え出した問題があります。解決策は、post_change_redirect値をpassword_resetビューに渡す引数の辞書に追加することです。

だから、これは私が今のように見えるものです:私はそれがあなたのためにそれをしない願っています

(r'^/password/$', password_change, {'template_name': 'testing/password.html', 'post_change_redirect': '/account/'}) 

!私は、この特定の機能のためのドキュメントが多少欠けていることに同意しますが、これは私のプロジェクトでまったく同じ問題を解決しました。

編集:私は本当にスクロールする必要がありました - あなたはすでにそれを含めています。お詫びしますが、私はそれをソートしてもらえれば幸いです。

3

:私はあなたの例を使用して、キーワードパラメータを使用しないように変更する必要がありました。

{% url django.contrib.auth.views.password_reset_confirm uid, token %} 

名前付きパラメータは、uidとトークンの両方が定義されている限り動作します。いずれかが定義されていない場合、または空白の場合は、同じエラーが発生します。

{% url django.contrib.auth.views.password_reset_confirm uidb36=uid, token=token %} 
+0

もう少し説明できますか? 「urls.pyにpassword_reset_confirmの行を追加してみてください」とはどういう意味ですか?上の例の3番目のURLはpassword_reset_confirmです。私はそれを私のurls.pyファイルに追加するべきですか? ありがとうございました – Joe

+0

私は間違いを見落として、上記の私のために働いたものを編集しました。 – dar

2

は私が終わるためにこれで苦労してきた問題は、このラインにありましたこのページのすべてとインターネット上の他のすべてのページを試してみる時間。最後に、私の場合の問題点を解決するために、私は私のpassword_reset_email.htmlテンプレートの上から

{% load url from future %} 

を削除する必要がありました。

また、urlスクリプトの "uidb36 = uid"にも注意してください。ここに私の完全なpassword_reset_email.htmlテンプレートがあります。少し時間を節約してくれることを祈っています:

{% autoescape off %} 
    You're receiving this e-mail because you requested a password reset for your user account at {{ site_name }}. 


Please go to the following page and choose a new password: 
{% block reset_link %} 
{{ protocol }}://{{ domain }}{% url django.contrib.auth.views.password_reset_confirm uidb36=uid token=token %} 
{% endblock %} 

Your username, in case you've forgotten:" %} {{ user.username }} 

Thanks for using our site! 

The {{ site_name }} team 

{% endautoescape %} 
関連する問題