在Django用户角色中分配权限

时间:2018-10-10 16:38:09

标签: django django-permissions

我想创建HR角色并将角色分配给用户。但是,当我分配给用户并检查分配给用户的用户权限时,它不会 我希望的正确权限。

role.py

from rolepermissions.roles import AbstractUserRole

class Hr(AbstractUserRole):
    available_permissions = {
        'Can add candidate rank': True,
        'Can change candidate rank': True,
        'Can delete candidate rank': True,
        'Can view candidate rank': True,
    }

model.py 的“排名”应用

from django.db import models

class CandidateRank(models.Model):
    """docstring forCandidate_History_Education."""
    candidate = models.CharField(max_length=50, blank=True, null=True)
    count = models.CharField(max_length=50, blank=True, null=True)

    def __int__(self):
        return self.candidate

显示如下的选择用户权限 ...

auth | user | Can add candidate rank
auth | user | Can change candidate rank
auth | user | Can delete candidate rank
auth | user | Can view candidate rank 

所以我不想,我想要这样***

rank | candidate rank | Can add candidate rank
rank | candidate rank | Can change candidate rank
rank | candidate rank | Can delete candidate rank
rank | candidate rank | Can view candidate rank 

0 个答案:

没有答案