Last active
December 14, 2015 21:49
-
-
Save tomviner/5154169 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
from django.contrib import admin | |
from django.db.models.loading import get_models | |
# BaseAdmin does things like default list_display to all fields | |
from core.admin import BaseAdmin | |
import models as legacy_models | |
for mod in get_models(legacy_models): | |
if mod not in admin.site._registry: | |
# no need for type(name, bases, dict), use a closure | |
class ModelAdmin(BaseAdmin): | |
model = mod | |
admin.site.register(mod, ModelAdmin) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment