Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add report section to the Django admin?

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.

like image 951
Al Bundy Avatar asked Nov 03 '12 15:11

Al Bundy


People also ask

What is Django Report Builder?

Django Report Builder is a GUI for Django ORM. Build custom queries and display results. Targets sys admins and capable end users who might not be able to program. gitlab.com/burke-software/django-report-builder.

How do I access my Django admin page?

To login to the site, open the /admin URL (e.g. http://127.0.0.1:8000/admin ) and enter your new superuser userid and password credentials (you'll be redirected to the login page, and then back to the /admin URL after you've entered your details).


1 Answers

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

like image 77
Calvin Cheng Avatar answered Oct 25 '22 16:10

Calvin Cheng