【发布时间】:2020-01-01 10:07:16
【问题描述】:
用户“Bob”的示例
Django 管理员:Home › Authentication and Authorization › Users › Bob
在 Django Admin 界面中修改用户时,在密码下显示:
未存储原始密码,因此无法查看此用户的密码,但您可以使用此表单更改密码。
但是,this form 链接失败并显示 Page not found 404,地址为:
http://127.0.0.1:8000/password/
而正确的 URL(有效)应该是:
http://127.0.0.1:8000/admin/auth/user/40/password/
经过一番搜索,我发现:Lib/site-packages/django/contrib/auth/forms.py:129:
class UserChangeForm(forms.ModelForm):
password = ReadOnlyPasswordHashField(
label=_("Password"),
help_text=_(
"Raw passwords are not stored, so there is no way to see this "
"user's password, but you can change the password using "
"<a href=\"{}\">this form</a>."
),
)
但我没有看到更改密码链接是如何在 href 中设置的,对我来说它看起来是空白的。我也不想更改 Django 源代码,因为当有更新时会出现相同的错误。如何让链接指向有效的更改密码页面?
【问题讨论】:
标签: python django django-admin