我尝试创建群组并为其添加一些权限。 这就是我所做的:
students = Group(name='Students')
students.save()
somemodel_ct = ContentType.objects.get(app_label='course', model='course')
can_view = Permission(name='Can View', codename='can_view_something',
content_type=somemodel_ct)
can_view.save()
can_modify = Permission(name='Can Modify', codename='can_modify_something',
content_type=somemodel_ct)
can_create = Permission(name='Can Create', codename='can_create_something',
content_type=somemodel_ct)
can_delete = Permission(name='Can Delete', codename='can_delete_something',
content_type=somemodel_ct)
can_delete.save()
但这对我来说似乎很难看,还有其他办法(除了去管理页面我想避免)
答案 0 :(得分:0)
您可以在模型中声明自定义权限:
<div class="col-xs-12 col-sm-8 col-md-6 col-lg-4">