0

is there a way of customizing my own admin panel , not in terms of styling. What i wish to achieve is a analytics tab , similar to wagalytics . The issue im having with wagalytics is that it is using google analytics , and google analytics is blocked by most adblockers and Mozilla fire fox , making the data really unreliable. As such i wish to utitlize other services like django-analytical to my wagtail administration page with a graph similar to that of wagalytics . However , i have not yet found any resources online that teaches me to override the admin and create my own customized panel (different from the customized tabs here ).

Could someone point me towards the right direction?

neowenshun
  • 860
  • 1
  • 7
  • 21
  • Are you trying to make a panel appear on editing pages? Or a page within admin that is available by the side menu on the left. – LB Ben Johnston May 08 '20 at 07:50
  • as a side menu on the left , i am looking through wagtailmodeladmins as of now (seems like its what i need) – neowenshun May 08 '20 at 08:21
  • To modify the side menu you need to use a hook. https://docs.wagtail.io/en/stable/reference/hooks.html#admin-modules modeladmin is for creating a CRUD style interface to existing models. – LB Ben Johnston May 08 '20 at 09:38
  • Do you have a package or something installable? Because I am looking for a alternative for google analytics and I cannot believe that nobody had this idea before? – rokdd Nov 18 '21 at 17:08

1 Answers1

1

To add a page (link) to the Wagtail admin menu, you can use the hook register_admin_menu_item.

Create a file my-app/wagtail_hooks.py and this will be run by Wagtail to hook in custom functionality.

rom django.urls import reverse

from wagtail.core import hooks
from wagtail.admin.menu import MenuItem

@hooks.register('register_admin_menu_item')
def register_frank_menu_item():
  return MenuItem('Frank', reverse('name-of-analytics-url'), classnames='icon icon-folder-inverse', order=10000)

You will need to set up the view with whatever reporting/graphs yourself, you could look into the source of wagalytics or simply serve whatever reporting django-analytics makes available.

If you want the templates your view use to extend the Wagtail admin templates, you can do this using the wagtailadmin/base.html. e.g. {% extends "wagtailadmin/base.html" %}. Note: you may need to add 'wagtail.admin', to your INSTALLED_APPS.

LB Ben Johnston
  • 4,751
  • 13
  • 29