I am currently hooking a large database up to a django site and want to populate the admin page with a number of models. I am using inspect to get a list of classes from each model file (one file per database in MySQL) and then registering them by name.
from django.contrib import admin import inspect from .models import auth # Auth for pair in inspect.getmembers(auth): # returns a tuple with the class name and ref model = tuple if tuple is not "_" and tuple.upper() == tuple: # it doesnt start with _ and does start with an uppercase admin.site.register(model)
Is there anything wrong with this code? Is getting class references like this bad practice? It just seems to easy to be true.