How to add report section to the Django admin?

后端 未结 2 1750
栀梦
栀梦 2021-02-12 22:07

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 repor

2条回答
  •  梦如初夏
    2021-02-12 22:37

    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

提交回复
热议问题