如何将报告部分添加到Django管理员? [英] How to add report section to the Django admin?

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

问题描述

我想在Django admin中实现报告部分。这意味着在管理主页中添加一个自定义部分,而不是模型列表,而是报告列表。我想将Django的管理表与过滤器一起使用,对所有可能的东西进行排序。



实现此目标的最佳方法是什么?我意识到这是一个大问题,因此我不一定要询问代码片段,只需对所需操作进行摘要即可:)



P.S。可以说,我的意思是通过自定义查询(queryset或它的调用方式)建立的组成模型。



PS2也许这个问题应该是这样的:如何在自己的管理视图中使用Django管理表功能?



PS3也许有一种方法可以向现有管理界面提供我自己的数据。这样,我不必做任何其他事情。我只想说不是模型,而是要使用此数据并将其显示在一个不错的表中,可以对其进行排序,过滤等。

因此,您尝试将新页面添加到django管理员中。



本节向您确切说明了如何操作- https://docs.djangoproject.com/en/dev/ref/contrib/admin /#adding-views-to-admin-sites



基本思想是在中添加所需的新网址urls.py ,就像您要为前端页面添加url一样。关键区别在于,您要添加的这些新网址应以 ^ admin / 开头,看起来类似于 ^ admin / my_special_link_in_admin ,并且该网址将指向您自己喜欢的位置的自定义视图功能。



例如

 (r'^ admin / my_special_link_in_admin / $','my_custom_admin_app.views.special_admin_page'),

因此,这是完全自定义的方式。我在这里指的是一个很好的教程- http://brandonkonkle.com/ blog / 2010 / oct / 4 / django-admin-customization-examples /



此外,如果您不想做太多工作,考虑使用Django Admin Plus- https://github.com/jsocol/django-adminplus



或者django-admin-views- https://github.com/frankwiles/django-管理员视图


I want to implement a report section in Django admin. This would mean adding a custom section in the admin homepage where instead of a list of models I would see a list of reports. I want to use Django's admin tables with filters, sorting, everything if possible.

What would be the "best" way of achieving this? I realize this is a "big" question so I'm not asking for code snippets necessarily, a summary of needed actions would be just fine :)

P.S. Be report I mean a "made up" model by custom queries (queryset or how it's called).

P.S.2 Maybe this question should be something like: How to use Django admin tables functionality in own admin view?

P.S.3 Or maybe there is a way of providing to the existing admin interface my own data. This way I don't have to do anything else. I just want to say instead of a model take this data and display it in a nice table which I can sort, filter etc etc.

解决方案

So you are attempting to add in new pages into the django admin.

This section explains to you exactly how you can do so - https://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-views-to-admin-sites

The basic idea is to add in new urls that you want in your urls.py as if you are adding urls for your "front end" pages. The key difference is that these new urls you are adding should start with ^admin/ and would look something like ^admin/my_special_link_in_admin and this url will point to your own custom view function at a location you so prefer.

E.g.

(r'^admin/my_special_link_in_admin/$', 'my_custom_admin_app.views.special_admin_page'),

So this is the way for complete customization. There's a very good tutorial which I refer to here - http://brandonkonkle.com/blog/2010/oct/4/django-admin-customization-examples/

In addition, if you don't want to do too much work, consider using Django Admin Plus - https://github.com/jsocol/django-adminplus

Or a django-admin-views - https://github.com/frankwiles/django-admin-views

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

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