1

だから私はUsers(django.contrib.auth.models import Userから)とUserProfilesを持っています。私のUserProfileビューには、編集リンクがあります。この編集リンクにより、ユーザーはユーザー設定を変更できます。フォームのパスワードセクションに、次のようなヘルプテキストが表示されます。

"Use '[algo]$[salt]$[hexdigest]' or use the change password form." 

「パスワード変更フォーム」は実際にはhttp://127.0.0.1:8000 / user / 1 / user_edit / password /へのリンクです。リンクをクリックすると、次のようなエラーメッセージが表示されます。

ViewDoesNotExist at /user/1/user_edit/password/

Could not import testdb.views.django.contrib.auth.views. Error was: No module named django.contrib.auth.views

私はドキュメントに従っています:https ://docs.djangoproject.com/en/dev/topics/auth/

私は何が間違っているのですか?これはdjangosテンプレートを使用する必要があると聞きましたが、それらをアプリテンプレートフォルダーにコピーする必要がありますか?もしそうなら、彼らはどこにいますか?

URLS.PY

from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('testdb.views',
url(r'^$', 'index'),
url(r'^^user/(?P<user_id>\d+)/$', 'user_detail'),
url(r'^user/(?P<user_id>\d+)/user_edit/$', 'user_edit'),
url(r'^user/(?P<user_id>\d+)/user_edit/password/$', 'django.contrib.auth.views.password_change', {'template_name': 'password_change_form'}),
)
4

2 に答える 2

2

testdb.views.django.contrib.auth.views間違ったURLパターンが定義されています:内部でpassword_changeビューを定義すると、 Djangoは検索を試みますpatterns('testdb.views',

2番目のパターンを追加します。

urlpatterns += patterns('django.contrib.auth.views',
  url(r'^user/(?P<user_id>\d+)/user_edit/password/$', 'password_change')
)

これで問題は解決するはずです。

于 2012-04-13T20:39:24.020 に答える
0

cfedermannには問題の解決策がありますが、最初にpassword_changeURLを定義した理由について混乱しています。この機能は管理者に組み込まれており、他のすべての管理ページと同様に、URLは管理者コード自体によってすでに定義されています。

于 2012-04-13T20:41:43.223 に答える