0
我正在嘗試創建組併爲其添加一些權限。 這是我做過什麼:如何以編程方式在Django中創建組和權限?
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()
但這似乎醜對我來說,是有
爲什麼這是醜陋的? –