django-nonrel + django-registrationの問題:予期しないキーワード引数 'uidb36'パスワードをリセットするとき

StackOverflow https://stackoverflow.com/questions/6323852

質問

私は使用しています django-nonrel登録 アプリ。パスワードをリセットしようとする場合を除き、物事は正常に機能しているようです。電子メールで送信されたリセットパスワードリンクをクリックすると、djangoはエラーメッセージを作成します。

password_reset_confirm() got an unexpected keyword argument 'uidb36'

私の質問:誰かがそれを見て、治療法を知っていますか?

編集:

問題は登録 auth_urls.pyによって引き起こされます-django contrib auth urls.pyのエントリを複製し、Django -nonrelのファイルのパッチ付きバージョンを囲んでいます。

なぜそこにあるのか、実際に削除したり、修正したりできますか?

役に立ちましたか?

解決 2

私の解決策は、登録 auth_urls.pyで定義されているurlpatternsをコメントし、django.contrib.authで定義されたurlpatternsのコピーとしてそれらを再定義することでした。

これが変更後の私のauth_urls.pyです:

"""
URL patterns for the views included in ``django.contrib.auth``.

Including these URLs (via the ``include()`` directive) will set up the
following patterns based at whatever URL prefix they are included
under:

* User login at ``login/``.

* User logout at ``logout/``.

* The two-step password change at ``password/change/`` and
  ``password/change/done/``.

* The four-step password reset at ``password/reset/``,
  ``password/reset/confirm/``, ``password/reset/complete/`` and
  ``password/reset/done/``.

The default registration backend already has an ``include()`` for
these URLs, so under the default setup it is not necessary to manually
include these views. Other backends may or may not include them;
consult a specific backend's documentation for details.

"""

from django.conf.urls.defaults import *

#from django.contrib.auth import views as auth_views

from django.contrib.auth import urls as auth_urls

urlpatterns = auth_urls.urlpatterns

'''
Commented out, this is what caused my problems:

urlpatterns = patterns('',
                       url(r'^login/$',
                           auth_views.login,
                           {'template_name': 'registration/login.html'},
                           name='auth_login'),
                       url(r'^logout/$',
                           auth_views.logout,
                           {'template_name': 'registration/logout.html'},
                           name='auth_logout'),
                       url(r'^password/change/$',
                           auth_views.password_change,
                           name='auth_password_change'),
                       url(r'^password/change/done/$',
                           auth_views.password_change_done,
                           name='auth_password_change_done'),
                       url(r'^password/reset/$',
                           auth_views.password_reset,
                           name='auth_password_reset'),
                       url(r'^password/reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
                           auth_views.password_reset_confirm,
                           name='auth_password_reset_confirm'),
                       url(r'^password/reset/complete/$',
                           auth_views.password_reset_complete,
                           name='auth_password_reset_complete'),
                       url(r'^password/reset/done/$',
                           auth_views.password_reset_done,
                           name='auth_password_reset_done'),
) 
'''

他のヒント

Django 1.6は、ベース36エンコードではなく、ユーザーのIDにベース64エンコードを使用します。

カスタムパスワードリセットURLがある場合は、UIDB36をUIDB64に置き換え、そのパターンに続くダッシュをスラッシュで置き換えて更新する必要があります。また、UIDB64パターンに一致する可能性のある文字のリストに「_」、「」、および「 - 」を追加します。

たとえば、urls.py in django 1.5-のこの行の行:

url(r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
    'django.contrib.auth.views.password_reset_confirm',
    name='password_reset_confirm'),

Django 1.6+でこれに変更する必要があります:

url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
    'django.contrib.auth.views.password_reset_confirm',
    name='password_reset_confirm'),

これが変更を詳述する公式の変更ログです。https://docs.djangoproject.com/en/1.6/releases/1.6/#django-contrib-auth-password-reset-uses-64-encoding-of-user-pk

私はただ変えなければなりませんでした uidb36 への議論 uidb64, 、 そのようです:

から:

url(r'^password/reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',

に:

url(r'^password/reset/confirm/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',

その後、パスワードリセットが再び動作し始めました。

私はあなたのpassword_reset_confirm urlのurls.pyに似たものに見えると思います

url(r '^accounts/password_reset/(?p [0-9a-za-z] {1,13}) - (?p [0-9a-za-z] {1,13} - [0-9a -za-z] {1,20})/$ '、password_reset_confirm、{' post_reset_redirect ':'/accounts/password_reset/complete/'}、name = "password_reset_confirm")、

Password_reset_email.htmlのリンクは{{{protocol}}}}}のように見えます。

UIB36を両方の場所のUIB64に変更するだけで、機能します。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top