如何获得从用户组继承的权限?

发布于 2024-08-16 08:18:23 字数 323 浏览 2 评论 0原文

我正在尝试找出 Django Groups,但网站上的文档非常简单。

例如,您可以使用装饰器 Permission_required() 检查权限,但是,这只检查您是否直接分配了权限。我已将用户分配到具有权限设置的组。当使用 Django 的权限系统时,它会忽略用户所属的组。

有没有办法让 Django 继承用户组的权限?

I'm trying to figure out Django Groups and the documentation is pretty bare on the site.

For example, you can use the decorator permission_required() to check the permissions, however, this only checks if you have assigned permissions directly. I have assigned Users to Groups which have Permissions setup. When using Django's permissions system, it ignores the Groups the User belongs to.

Is there any way to get Django to inherit permissions from the User's Groups?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぺ禁宫浮华殁 2024-08-23 08:18:23

Django 会自动从组继承权限。您的安装或数据库可能存在一些问题(例如在没有完成syncdb的情况下使用自定义权限),或者您可能将错误的参数传递给装饰器。

例如,如果您在名为 blog 的应用程序中有一个名为 post 的模型,则装饰器将按如下方式使用:

@permission_required('blog.delete_post')

Django does automatically inherit permissions from groups. There may be some problem in your installation or database (such as using a custom permission without having done a syncdb), or you might be passing the wrong argument to the decorator.

If you have a model named post in an app named blog for example, the decorator would be used like this:

@permission_required('blog.delete_post')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文