Binary Lion Studios

I code for fun and for food.

Register all models in admin

Quick and painless way to register all models in a module with the admin app in Django.

appname/admin.py
1
2
3
4
5
6
7
8
9
10
from appname import models
from django.contrib import admin

import insepct

# register all models with admin
for name in dir(models):
    obj = getattr(models, name)
    if inspect.isclass(obj):
        admin.site.register(obj)

All the models for appname have been registered.