Created
September 28, 2012 17:59
-
-
Save sligodave/3801283 to your computer and use it in GitHub Desktop.
Register all models that extend a certain base abstract model.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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