Django Shortcut: Automated Admin Model Registration

2009-11-28

As we all know, Django has a rather lovely admin package. However, in a module’s admin.py, all desired models must manually be registered with django.contrib.admin.site.register.

No longer, say I. The only time I use the admin package is during development, I roll my own for production. So, it stands to reason that I wouldn’t want to spend much time registering models with admin, especially if I’m going to be changing the models around!

And so, as the cliché goes: without further ado, I present my snippet:

The primary downside with this is that there’s a lack of customization. Although, as I said, I use the admin views only for development, so customization is most often not a concern of mine.

← all posts

michael schade

I built out engineering and operations teams at Stripe as employee #20 from 2012 to 2019; now I'm working on something new. I like helping people, photography, reading, gym, traveling, and learning new things. Say hi! 🏳️‍🌈