Django user not getting the assigned group's permissions

偶尔善良 提交于 2020-01-05 07:58:31

问题


I am using django admin back end for creating user groups. I created a group called admin and assigned several permissions to it.

But when I assign this group admin to a user the permissions of that group are not automatically assigned to the user.

The django docs say that:

A user in a group automatically has the permissions granted to that group. 
For example, if the group Site editors has the permission can_edit_home_page, 
any user in that group will have that permission.

Can someone please tell me if I understood it correctly or not? Or do I need to write some code myself to assign permissions of a group to a user.

I am using django rest framework and south and postgres as database.

Also I checked using the django shell that,

when I assign a user specific permissions manually they get assigned. Also when I assign a group specific permissions they also get assigned to that group.

But when I assign a group to a user, the group gets assigned but the the groups permissions are not.


回答1:


The group permissions do not get copied to the user as user permissions, but the user should still have all the groups permissions.

Example:

User Anton
  - can add X

Group Admin
  - can change X
  - can delete X

Anton can only add X as long as he is not in the Admin Group. When he is member of the Group he will be able to change/delete X. If you view the user permissions in django-admin they will still look the same though.



来源:https://stackoverflow.com/questions/23757901/django-user-not-getting-the-assigned-groups-permissions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!