def get_real_instance_class(self):
        """
        Normally not needed.
        If a non-polymorphic manager (like base_objects) has been used to
        retrieve objects, then the real class/type of these objects may be
        determined using this method.
        """
        # the following line would be the easiest way to do this, but it produces sql queries
        # return self.polymorphic_ctype.model_class()
        # so we use the following version, which uses the ContentType manager cache.
        # Note that model_class() can return None for stale content types;
        # when the content type record still exists but no longer refers to an existing model.
        try:
            model = ContentType.objects.get_for_id(self.polymorphic_ctype_id).model_class()
        except __HOLE__:
            # Django <1.6 workaround
            return None

        # Protect against bad imports (dumpdata without --natural) or other
        # issues missing with the ContentType models.
        if model is not None \
                and not issubclass(model, self.__class__) \
                and not issubclass(model, self.__class__._meta.proxy_for_model):
            raise RuntimeError("ContentType {0} for {1} #{2} does not point to a subclass!".format(
                self.polymorphic_ctype_id, model, self.pk,
            ))
        return model
dataset/ETHPy150Open chrisglass/django_polymorphic/polymorphic/models.py/PolymorphicModel.get_real_instance_class