在 Django 管理面板的代码中设置模型级别权限

发布于 2024-09-25 15:59:40 字数 71 浏览 1 评论 0原文

有没有办法通过代码来实现模型的权限?我有大量模型,我希望其中一些模型只能由管理员查看,而不能添加它们。

请建议。

Is there a way to implement the permissions for models through the code? I have a large set of models and I want some of the models to be just viewable by the admin and not the ability to add them.

Please suggest.

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

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

发布评论

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

评论(2

葮薆情 2024-10-02 15:59:40

您可以通过管理站点本身设置权限。有关说明,请参阅 django 图书章节中的“用户、组和权限”部分:

You can set permissions through the admin site itself. For instructions, see the "Users, Groups and Permissions" section in the django book chapter:

枫以 2024-10-02 15:59:40

在这里找到解决方案: http://code.djangoproject.com/wiki/RowLevelPermissions

的工作方式我需要。

Found the solution here: http://code.djangoproject.com/wiki/RowLevelPermissions

works the way I needed.

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