Created
February 13, 2012 13:01
-
-
Save 0xPr0xy/1816784 to your computer and use it in GitHub Desktop.
autoregister.py
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
def autoregister(*app_list): | |
from django.db.models import get_models, get_app | |
from django.contrib import admin | |
from django.contrib.admin.sites import AlreadyRegistered | |
for app_name in app_list: | |
app_models = get_app(app_name) | |
for model in get_models(app_models): | |
try: | |
admin.site.register(model) | |
except AlreadyRegistered: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment