管理界面的激进使用
我想知道......
是否有可能在 Django 中创建完全独立于模型甚至应用程序的管理页面?
我正在考虑类似仪表板或控制界面的东西,它们只从其他模型收集数据,但没有自己的数据。
如果是这样,还有更多参考或链接吗?
谢谢
I was wondering....
Is it possible in Django the creation of an Admin page completely independent of a model or even a app?
I was thinking in something like a dashboard or interface of control, that only gather data from other models but does not have it's own.
If so, any further reference or link?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
正如 Ben 所说,您可以通过为仪表板页面创建视图功能来做到这一点。视图函数本身可以位于项目中的任何位置,但 Django 需要知道它在哪里(即与 Django 的默认模型管理视图不同,您需要在 urls.py 文件中定义视图,该文件是姜戈知道)。
要添加的一件事是,由于我假设此仪表板页面只能通过管理界面访问,因此您希望使用一些内置身份验证装饰器来保护它(例如 login_required 或 permission_required)。
As what Ben said, you can do this by creating a view function for your dashboard page. The view function itself can live anywhere within your project, but Django needs to know where it is (i.e. unlike the Django's default model admin views, you need to define your view in a
urls.py
file that is known to Django).One thing to add, since I'm assuming that this dashboard page is only accessible via your admin interface, you want to secure it using some of the built-in authentication decorators (e.g. login_required or permission_required).
这样做是完全有可能的。您可以使用常规视图执行此操作,然后创建扩展“admin/base_site.html”模板的模板,如下所示:
您还可以像这样执行面包屑:
然后将您想要的任何内容放入“内容”块内。
It is entirely possible to do this. You can do this with regular views, and then create templates that extend the "admin/base_site.html" template like so:
You can also do breadcrumbs like this:
And then put whatever content you want inside of the "content" block.
我使用 django-admin-tools 来创建仪表板。使用此应用程序创建自定义仪表板模块非常容易。
还有另一个具有类似目的的应用程序(nexus)。我没有亲自尝试过,但看起来也不错。
I'm using django-admin-tools for creating dashboards. It is quite easy to create custom dashboard modules with this app.
There is also an another app (nexus) with similar purposes. I haven't tried it by myself but it looks good too.
Nexus 似乎正是正确的选择。
我自己正在使用它并且非常有用。
截至目前,可用的模块并不多,我认为只有两个。
背后的人制作的
它是由 Disqus链接:Nexus
将添加有关如何添加您自己的模块的文档。
希望这有帮助。
Nexus seems like just the right thing.
I am using it myself and its very useful.
As of kow there are not alot of moudles availale, only two i think.
It was made by the guys behind Disqus
Link: Nexus
There are going to add documentation on how to add your own modules.
Hope this helps.