Created
June 10, 2014 10:34
-
-
Save micrypt/9eddb1d49f58abeb71b2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# utils/admin.py | |
from django.contrib import admin | |
from django.db.models import get_models, get_app | |
def autodiscover(name, exclude=[]): | |
excluded = [ model.__name__ for model in exclude ] | |
current_app = name.replace('.admin', '') | |
for model in get_models(get_app(current_app)): | |
if model.__name__ not in excluded: | |
admin.site.register(model) | |
# accounts/admin.py | |
from utils.admin import autodiscover | |
from .models import Profile | |
autodiscover(__name__, exclude=[Profile]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment