How to add report section to the Django admin?
Solution 1
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
Solution 2
Additionally, there is this nice app:
"admin_reports" is a Django application to easily create data aggregation reports to display inside Django admin.
The Django admin is very much centered on models and it provide a quick and simple way to create a GUI for the CRUD interface, but often there's the need to display data in an aggregate form, here's where admin_reports comes handy.
The idea is to have a class similar to
ModelAdmin
(fromdjango.contrib.admin
) that allow to display derived data concentrating on implementing the aggregation procedure.
Related videos on Youtube
Al Bundy
Updated on September 24, 2022Comments
-
Al Bundy over 1 year
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.
-
Al Bundy over 11 yearsYes, I want new pages but I don't want to use my own table templates and functionality. This is huge work! :) I want the nice Django admin to work for custom data also, not just model data :D
-
Calvin Cheng over 11 yearsYup. I get it. Use github.com/jsocol/django-adminplus as mentioned in my updated answer.
-
Al Bundy over 11 yearsWill this adminplus take of my hands the need to write table sorting, for example?
-
Alvaro Rodriguez Scelza about 3 yearsSadly, django-admin-reports is no longer an option. It is deprecated since it does not support django 3 :(. It only does until django 2.