Django 身份:组长
我的应用程序有数百个用户和大约 10 到 20 个组。现在客户想给予组长特殊的特权。
您将如何做到这一点(以可重用的方式)?
My application has some hundred users and about 10 to 20 groups. Now the customer wants to give special privileges to group leaders.
How would you do this (in a reusable way)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以创建一个扩展
group
类的新模型,并将其添加到user
(领导者)的新外键You can create a new model that extends the
group
class and add it a new foreign key to auser
(the leader)下一个片段使组领导者可以在 django admin 中使用:
The next snippet makes the group leaders available in django admin: