gpt4 book ai didi

python - Django 管理员的有效用例?

转载 作者:太空狗 更新时间:2023-10-29 17:53:49 25 4
gpt4 key购买 nike

我想建立一个 django 站点,其中一组受信任的用户可以编辑他们的个人资料信息。让每个受信任的用户都通过 django 管理界面是否有意义?我只希望他们能够查看和编辑自己的信息(显然)。这似乎不符合 django 人定义“信任”的方式,尤其是粗体部分......

来自 The Django Book, Chapter 18 :

The admin is designed to be used by people who you, the developer, trust. This doesn’t just mean “people who have been authenticated;” it means that Django assumes that your content editors can be trusted to do the right thing.

This means that there’s no “approval” process for editing content — if you trust your users, nobody needs to approve of their edits. It also means that the permission system, while powerful, has no support for limiting access on a per-object basis. If you trust someone to edit their own stories, you trust them not to edit anyone else’s without permission.

这是适合 django 的管理模块的那些用例之一,还是它只是一个不受信任的用户的专用 View ?

最佳答案

不,Django 管理不适合个人用户配置文件,每个用户都可以查看和编辑所有其他用户配置文件。这更适合必须同时管理所有用户的管理员。

您需要构建的是用户个人资料页面。 Django 已经有一个很好的登录系统,由 django.contrib.auth 模块提供。您可以轻松地将其集成到您的页面中,这正是 Django 管理员用来验证用户身份的内容。

接下来,您必须构建一个简单的页面,以根据用户模型公开该特定用户的个人资料信息。这应该相对轻松,因为它只需要一个 View 和一个模板,并且模板可以利用 ModelForms。

关于python - Django 管理员的有效用例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/498199/

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