列出Django前端应用程序的权限列表

时间:2013-10-01 06:53:38

标签: django django-permissions

我想列出django为特定应用创建的模型的权限,就像在创建用户时在django后端完成的那样:

app_name | model_name | can add model_name

怎么做?

1 个答案:

答案 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>]