django管理员的有效用例? [英] Valid use case for django admin?

查看:80
本文介绍了django管理员的有效用例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个django网站,某些可信赖的用户组可以编辑他们的个人资料信息。让每个受信任的用户通过django管理界面是否有意义?我只希望他们能够看到和编辑自己的信息(显然)。这似乎不符合django人定义信任的方式,特别是粗体的位置。

I want to build a django site where a certain group of trusted users can edit their profile information. Does it make sense to have each trusted user go through the django admin interface? I'd only want them to be able to see and edit their own information (obviously). It doesn't seem like this fits the way the django people define "trust", especially the bolded bit...

Django Book,第18章


管理员被设计为使用
的人,你,开发商,信任。
这不仅仅意味着
已经被认证的人,这意味着
Django假定您的内容
编辑者可以信任做正确的

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的管理模块的用例,还是只是非信任用户的专用视图?

Is this one of those use cases that fits with django's admin module, or is it just a specialized view for a non-trusted user?

推荐答案

不,Django管理员不适合个人用户个人资料,每个用户都可以查看和编辑所有其他用户个人资料。这更适合于必须一次管理所有用户的管理员。

No, the Django admin is not suited for individual user profiles, each user would be able to see, and edit, all other user profiles. This is suited more to an administrator who has to manage all the users at once.

您需要构建的是用户个人资料页面。 Django已经有一个很好的登录系统,由django.contrib.auth模块提供。您可以轻松地将其整合到您的网页中,以及Django管理员用来验证用户的方式。

What you need to build is a user profile page. Django already has a nice login system courtesy of the django.contrib.auth module. You can easily integrate this into your pages, and its exactly what the Django admin uses to authenticate users.

接下来,您必须构建一个简单的页面,基于用户模型的用户个人资料信息。这应该是相对无痛的,因为它只需要一个视图和一个模板,模板可以利用ModelForms。

Next you'll have to build a simple page that exposes that specific user's profile information based on their User model. This should be relatively painless as it will only require one view and one template, and the template can take advantage of ModelForms.

这篇关于django管理员的有效用例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆