同时使用 Django-admin 和自定义用户特定的管理员

发布于 2024-09-25 05:54:57 字数 457 浏览 5 评论 0原文

我正在创建一个由 Django 驱动的网站,该网站将包含大量应用程序(博客、商店、作品集等),这些应用程序将由 5 个人左右进行编辑,到目前为止,我在设计所有内容时都考虑到了 Django 管理员。

我开始意识到这是一种非常糟糕的思维方式 - 事实上 - Django 管理实际上应该只适用于顶级管理员,并且应该用于管理网站,而不是管理网站对此作出贡献。

我写出了功能集,并意识到整个网站应该拥有的应用程序数量(站点地图、邮件程序、联系表格、评论、标签等)远远大于编辑器应该访问的功能数量(CRUD 操作)用于博客/关于部分等)。

更好的做法是构建一个基于复杂权限的 Django 管理系统,还是构建第二个自定义“编辑器”管理系统来同时运行。

我认为这是应该在文档中讨论的事情,因为在我意识到这一点之前,我在理解如何将网站分解为应用程序方面遇到了很多困难,因为我在设计所有内容时都考虑到了管理员(以及实际用户的需求)应该在管理员中看到)

I'm creating a Django powered website that will have numerous applications (Blog, Shop, Portfolio, etc.) that will be edited by 5 or so people, and I have so-far been designing everything with the Django admin in mind.

I have come to realise that this is a very bad way of thinking -as really- the Django admin should really only be for top level administrators, and should be used for exactly that: administrating the website, not contributing to it.

I wrote out the feature-set and realised that the number of applications the entire website should have (sitemaps,mailers,contactforms,comments,tags etc.)is much much larger than the number of features the editor should have access to (CRUD actions for blog/about section etc).

Is it better practice to build a complex permission based Django admin, or build a second custom "editors" admin to run concurrently.

I think this is something that should be discussed in the documentation, as until I realised this, I had a lot of trouble understanding how to break the website down into applications, as I was designing everything with the admin in mind (and what actual user should see in the admin)

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

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

发布评论

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

评论(2

北座城市 2024-10-02 05:54:57

我认为你应该构建一个单独的“多样化”管理应用程序。以下是我所看到的优点和缺点:

优点:

  1. 无需篡改管理员或使用 hack 来获取特定功能。考虑到您的要求,我怀疑您需要几个这样的。

  2. 与管理员解耦。虽然 Admin非常很有用,但将您的应用程序与它紧密耦合并不是一个好主意。如果你正在调整它,那就更是如此。您必须留意 Admin 中可能会破坏您的应用程序的任何更改。

  3. 自定义样式。我想视觉吸引力可能在您的列表中不是很重要,但设置应用程序的样式比管理应用程序要容易得多。

  4. 将真正的超级用户与“直线管理员”分开。仅让高级用户看到系统的真实内部结构。

缺点:

  1. 你会重新发明轮子。通用视图使这变得更容易,但您最终仍然会重复功能或功能。

  2. 测试。管理应用程序被广泛使用并且经过了相当好的测试。您无需编写任何单元测试即可使用它(大多数情况下)。如果您构建自己的测试套件,则必须围绕它构建广泛的测试套件。

I'd argue that you should build a separate "diverse" admin app. Here are the pros and cons as I see them:

Pros:

  1. No need to tamper with Admin or use hacks to get specific features. I suspect you'll need several such given your requirements.

  2. De coupling from Admin. While Admin is very useful it is a bad idea to tightly couple your app with it. All the more so if you are tweaking it. Your would have to watch out for any changes in Admin that would break your app.

  3. Custom styling. I guess visual appeal may not be high on your list but it is far more easier to style your apps than the Admin app.

  4. Separate the really super users from "line admins". Let only the power users see the real innards of your system.

Cons:

  1. You'd be reinventing the wheel. Generic views make this easier but you'd still end up duplicating features or featurelets.

  2. Testing. The Admin app is widely used and is fairly well tested. You can use it without writing any unit tests (for most part). If you build your own you'll have to build an extensive test suite around it.

谈情不如逗狗 2024-10-02 05:54:57

我认为这是一个见仁见智的问题。但就我个人而言,我更喜欢创建一个单独的管理员并将用户组链接到该管理员,而不是同时使用主管理员。

这样,当出现问题时,您可以轻松地了解其他用户的一切情况。这一切都取决于你的情况,所以 YMMV

It is a matter of opinion I think. But personally I prefer to create a separate admin and link a user group to that instead of using the main admin for both.

That way you can easily see how everything looks for the other users when there's a problem. It all depends on your situation though, so YMMV

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