允许用户仅更改自己的密码/详细信息

时间:2014-09-30 13:11:31

标签: django django-models django-admin

我是Django的新手,并且一直在尝试使用Django Admin。

我可以看到超级用户如何为其他用户授予某些页面的权限,例如,The Django Book教你如何让用户只能编辑作者,而不是添加他们。但是,我无法让用户更改自己的详细信息,但所有用户'的信息。

权限列表中的选项如下:

admin | log entry | Can add log entry
admin | log entry | Can change log entry
admin | log entry | Can delete log entry
auth | group | Can add group
auth | group | Can change group
auth | group | Can delete group
auth | permission | Can add permission</option>
auth | permission | Can change permission
auth | permission | Can delete permission
auth | user | Can add user
auth | user | Can change user
auth | user | Can delete user
books | author | Can add author
books | author | Can change author
books | author | Can delete author
books | book | Can add book
books | book | Can change book
books | book | Can delete book
books | publisher | Can add publisher
books | publisher | Can change publisher
books | publisher | Can delete publisher
contenttypes | content type | Can add content type
contenttypes | content type | Can change content type
contenttypes | content type | Can delete content type
sessions | session | Can add session
sessions | session | Can change session
sessions | session | Can delete session

1 个答案:

答案 0 :(得分:2)

Django管理员不适合普通用户。如果他们具有管理员权限,则可以在/admin/password_change/更改自己的密码。如果他们不是管理员,您将必须编写自己的视图,让他们更改密码。请务必永远不要user.password = new_password但始终使用user.set_password(new_password),以便正确进行哈希处理。