gpt4 book ai didi

django - 现在如何在Django中处理每个对象的权限?

转载 作者:行者123 更新时间:2023-12-03 10:59:56 25 4
gpt4 key购买 nike

在正式文档中遇到以下内容之前,我将使用django-guardian:

https://docs.djangoproject.com/en/stable/topics/auth/customizing/#handling-authorization-in-custom-backends

Permissions can be set not only per type of object, but also per specific object instance. By using the has_add_permission(), has_change_permission() and has_delete_permission() methods provided by the ModelAdmin class, it is possible to customize permissions for different object instances of the same type.



这是否意味着较新版本的Django不再需要django-guardian?

请说清楚。

最佳答案

确实,在阅读文档时,我很高兴Django可以开箱即用especially in the admin来满足“按对象权限检查”的要求,并且了解如何激活它是一个时间问题。
但是,this does not seem to always be the case
Django undoubtedly strives为此类实现提供了基础(API),但是此实现有时需要良好的编码技能和Django理解。
开发人员将通过creating the app将这些工具组合在一起,以满足其需求。这可能很容易,也可能不那么容易!
这些矛盾的信息构成了我的网络爬网的基础,该网络侧重于以某种方式有效地解决“按对象权限”问题的解决方案……满足我项目的需求或规模,当然还有我自己的编码技能和Django到目前为止的理解。
Django-guardian似乎是为此目的最强大,功能最全面的应用程序,并且在管理集成方面也有一个3 years old open issue
还有其他more lightweight django applications也可以满足生产稳定的特定需求。
在尝试通过这种棘手的任务实现收支平衡时,我倾向于使用django-rules,因为它简单易用,并专注于我的需求。

关于django - 现在如何在Django中处理每个对象的权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33138477/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com