Skip to content

Instantly share code, notes, and snippets.

@sligodave
Created September 28, 2012 17:59
Show Gist options
  • Save sligodave/3801283 to your computer and use it in GitHub Desktop.
Save sligodave/3801283 to your computer and use it in GitHub Desktop.
Register all models that extend a certain base abstract model.
from django.contrib import admin
from django.db.models import get_models, get_app
from models import BaseModel
app = get_app('app_name')
for model in get_models(app):
if issubclass(model, BaseModel):
try:
admin.site.register(model)
except admin.sites.AlreadyRegistered:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment