def _get_real_admin_by_model(self, model_class):
        # In case of a ?ct_id=### parameter, the view is already checked for permissions.
        # Hence, make sure this is a derived object, or risk exposing other admin interfaces.
        if model_class not in self._child_models:
            raise PermissionDenied("Invalid model '{0}', it must be registered as child model.".format(model_class))

        try:
            # HACK: the only way to get the instance of an model admin,
            # is to read the registry of the AdminSite.
            return self._child_admin_site._registry[model_class]
        except KeyError:
            raise ChildAdminNotRegistered("No child admin site was registered for a '{0}' model.".format(model_class))
dataset/ETHPy150Open chrisglass/django_polymorphic/polymorphic/admin.py/PolymorphicParentModelAdmin._get_real_admin_by_model/original