Django AdminSite - 实施困难还是容易?
有人实现了自己的 AdminSite 吗?基本实施的容易/困难程度如何?
我正在构建一个“cms”,它在某些方面将非常大且相当复杂,我想知道使用像 AdminSite 这样的东西是否会节省一些时间。我宁愿不必为管理操作和内联等进行自己的实现(我知道我可以只使用内联表单,但这并不像 inlines = [Foo] 那么简单)。
当使用自定义AdminSite时,进一步的自定义是否等同于自定义标准Django管理?
Has anyone implemented their own AdminSite? How easy/hard was the basic implementation?
I'm in the midst of building a "cms" that's going to be quite large and decently complex in some areas and I'm wondering if using something like AdminSite would save some time. I'd rather not have to make my own implementation for admin actions and inlines and the like (I know I can just use inline forms but that's not as simple as inlines = [Foo]).
When using a custom AdminSite, is further customization equivalent to customizing the standard Django admin?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您已阅读管理站点文档。这是一个冗长的文档,但添加自定义功能的两个主要钩子是通过自定义 URL 以及在您自己的
AdminSite
和ModelAdmin
对象中修改标准视图。一旦您将这些挂钩并映射了 url,就像构建任何其他 Django 应用程序一样,只是模板不是您的,因此它们有点难以管理和适应。但它允许您做额外的练习,例如添加 表单向导 到管理站点,或者将所有内容拆分为多个表单,并将它们呈现在模板中的单个 HTMLform
元素中,对GET
/进行自定义处理POST
请求等。我过去曾使用它来创建用于显示自定义报告的视图,并为员工创建自定义编辑场景。我的意见是你应该尽可能多地接吻。管理站点主要是关于通用视图和通用演示。一定要扩展,但如果您覆盖模板块,请务必小心,并在覆盖未包含在块中的内容之前三思而后行。某些管理站点功能具有某些表示假设,并且 Django 附带的 JS 客户端应用程序也做了一些假设(这就是我在以前添加动态内联模型时所想到的),因此如果您愿意,这将是一项相当艰巨的任务喜欢推出完全不同的演示文稿。
无论如何,答案是肯定的!管理站点将为您提供更多用于交互式管理模型数据的功能。我不知道您需要对管理进行多大程度的自定义,但是 CMS、专用管理应用程序和管理集成应用程序确实令人大开眼界。据我回忆,Django CMS 被誉为目前最好的开源 Django CMS我可以看到它滚动它自己的自定义更改/列表视图。 Rosetta 是一款仅限管理网站的应用程序,可让您以交互方式编辑翻译文件,并且具有详尽的管理界面!如果您在 bitbucket 和 github 上货比三家,您会发现更多示例,它应该可以帮助您最好地了解需要投入多少精力。
You've read the admin site docs. It's a lengthy document, but two main hooks for adding custom functionality is through custom urls and modified standard views in your own
AdminSite
andModelAdmin
objects. Once you hook those in and the urls get mapped, it's just like building any other Django application, only that the templates aren't yours, so they're are a bit hard to manage and take getting used to. But it allows you to do additional gymnastics, like adding a form wizard to the admin site or splitting everything into multiple forms and rendering them in a single HTMLform
element in the templates, doing custom handling ofGET
/POST
requests, etc.I've used it in the past to create views for displaying custom reports and to create custom editing scenarios for the staff. My opinion is that you should KISS as much as possible. The admin site is all about generic views and generic presentation. Do expand, but be cautious if you override template blocks and think twice before you override something that's not wrapped in a block. Certain admin site features have certain presentation assumptions and the JS client app that's shipped with Django makes some too (that's what I've figured when working with adding dynamic inline models way back), so it'd be quite an undertaking if you'd like to roll a completely different presentation.
The answer in any case is YES! The admin site will provide you with more features for managing your model data interactively. I don't know how extensively you'd need to customize the admin, but there are CMSs, dedicated admin apps and admin integrated apps that are a real eye-opener. Django CMS, as I recalled, has been praised as the best open-source Django CMS out there and from what I can see it rolls it's own cust change/list views. Rosetta is an admin site only app that allows you to edit your translation files interactively and has an exhaustive admin interface! If you shop around on bitbucket and github you'll find many more examples, it should help you figure out best how much effort you'd need to put into it.
两者
如果您同意它不完全按照您的意愿行事,那么它几乎会自动为您完成。如果您需要对某些事情进行细粒度控制,那么在不了解管理代码的内部结构的情况下可能很难进行自定义。
Both
If you are OK with it not doing exactly what you want its pretty much done for you automatically. If you need fine grain control over certain things it can be hard to customize without knowing the internals of the admin code.
django admin 更适合所有类型的用户界面,在某些情况下使用可能不直观..
定制它的外观很容易,但扩展它却有些困难。在这种情况下,你最好设计自己的视图。
the django admin is more of a one size fits all kind of ui which may not be intuitive for use in some cases ..
customizing its look is easy but extending it is some how hard. you are better off designing your own views in that case.