Django用户未获得分配的组的权限 [英] Django user not getting the assigned group's permissions

查看:217
本文介绍了Django用户未获得分配的组的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用django admin后端创建用户组.我创建了一个名为admin的组,并为其分配了多个权限.

但是当我将此组admin分配给用户时,该组的权限不会自动分配给该用户.

django文档说:

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.

有人可以告诉我我是否正确理解?还是我需要自己编写一些代码来将组的权限分配给用户.

我正在使用django rest框架以及south和postgres作为数据库.

我也使用django shell进行了检查,

当我手动分配用户特定的权限时,他们将被分配.同样,当我分配特定于组的权限时,它们也会同时分配给该组.

但是,当我向用户分配组时,会分配该组,但未分配组权限.

解决方案

组权限不会作为用户权限复制到用户,但用户仍应拥有所有组权限./p>

示例:

User Anton
  - can add X

Group Admin
  - can change X
  - can delete X

只要Anton不在管理员组中,他就只能添加X.当他成为该组的成员时,他将能够更改/删除X.但是,如果您在django-admin中查看用户权限,则它们仍然看起来相同.

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.

解决方案

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.

这篇关于Django用户未获得分配的组的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆