如何将自定义部分添加到Django管理主页? [英] How do you add a custom section to the Django admin home page?

查看:51
本文介绍了如何将自定义部分添加到Django管理主页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Django管理员中,您向管理员注册的每个应用都有其自己的部分。我想添加一个与任何应用程序都不相关的自定义部分以进行报告。我该怎么做?

In the Django admin each app you have registered with the admin gets its own section. I want to add a custom section for reporting that isn't associated with any app. How do I do that?

推荐答案

要添加与应用程序不相关的部分,您必须覆盖管理索引模板。在项目模板目录中创建一个admin /目录,并将文件django / contrib / admin / templates / admin / index.html复制到其中。然后,您可以将所需的任何标记添加到此文件。唯一的缺点(不幸的是,目前尚无好的方法)是,如果您升级Django,则必须注意对index.html文件的任何更改,并将这些更改复制到您的版本中。好吧。

To add a section not associated with an app, you'll have to override the admin index template. Create an admin/ directory in your project templates directory, and copy the file django/contrib/admin/templates/admin/index.html into it. Then you can add whatever markup you want to this file. The only downside (unfortunately there's no good way around it at the moment) is that if you upgrade Django, you'll have to be on the lookout for any changes to that index.html file, and copy those changes over into your version as well.

这篇关于如何将自定义部分添加到Django管理主页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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