O Hai Django AdminPlus
Last night, as happens sometimes, I was wishing it was possible to add some of our custom admin views to the Django admin’s index page. It’s kind of a pain to have to type the URL every time, especially when talking to other people: “It’s in the admin, but no, you can’t… just go to this URL.”
So I was reading the Django admin docs and, frankly, they aren’t great. They tell you about the benefits of subclassing AdminSite
, or running multiple AdminSite
s, but they never really mention how to do it.
So, with a little trial and error, I wrote my AdminSite
subclass and figured out how to use it. It simplified a bunch of code in our custom admin app, so I thought I would share it.
Here’s Django AdminPlus (and on PyPI).
AdminPlus adds a method, admin.site.register_view
, that connects an arbitrary view function to your admin, and puts a link to it on the admin index page. If you put calls to register_view
in someapp/admin.py
, they’re picked up during the normal admin.autodiscover()
process.
If no name is given we try to guess from the name of the view function.
That’s about it! Read the README and the other docs and enjoy!