Ive changed certain parts of my admin page and played around extending the templates (so I have the file structure set up and working). I now want to go a bit further.
I want to add a column next to the 'recent activity' column on the admin page which would list all the most recent django-notifications the admin has received.
I am guessing I'd extend the base.html and add my notifications there. My first question is is this the best place to do this?
The next, bigger thing is that I would need to modify the original views.py file to do this. Surely this isnt a good idea? Poking around in the Django Admin views.py sounds like a terrible idea and makes me think that this kind of thing shouldnt be done, however id still like to know for sure before I give up on it.
I can find information on adding views to Django Admin, but nothing on adding content like this to the admin front page.
Thank you.
This won't be overly difficult to do.
A rough outline, you'll need to use your own AdminSite, and overwrite the
indexmethod (this is the method which renders the main view). Something like this:Notice I've also added in a new index_template. This is what the
indexmethod will use to render it's response. So we had better set that up. We'll extend the oldindex.htmland just add in our extra code in the bit that we want.And this should do the trick :) So, no. You don't really have to go messing around with anything you shouldn't be.
You'll want to register the
MyAdminSiteclass as your new admin. There are clear instructions to do that in the django docs.However... It is always worth thinking about the first few lines from the django-admin docs:
I would go a step further and say it should probably only be used by fellow developers. It's far to easy for others to cause major problems. So depending upon the reason why you want to add in these notifications here, it may or may not be a good thing to do.
I hope this helps :)