我想列出django为特定应用创建的模型的权限,就像在创建用户时在django后端完成的那样:
app_name | model_name | can add model_name
怎么做?
答案 0 :(得分:0)
您可以从权限模型中检索它,例如:
>>> Permission.objects.filter(content_type=ContentType.objects.get(app_label='auth',
model='user'))
[<Permission: auth | user | Can add user>, <Permission:
auth | user | Can change user>, <Permission: auth | user | Can delete
user>]