(self, model, levels=None)
return subclasses
Given a Model class, find all related objects, exploring children
        recursively, returning a `list` of strings representing the
        relations for select_related
Given a Model class, find all related objects, exploring children
        recursively, returning a `list` of strings representing the
        relations for select_related
Given a Model class find all related objects exploring children recursively returning a list of strings representing the relations for select_related
def _get_subclasses_recurse(self, model, levels=None):
        """
        Given a Model class, find all related objects, exploring children
        recursively, returning a `list` of strings representing the
        relations for select_related
        """
        related_objects = [
            f for f in model._meta.get_fields()
            if isinstance(f, OneToOneRel)]

        rels = [
            rel for rel in related_objects
            if isinstance(rel.field, OneToOneField)
            and issubclass(rel.field.model, model)
            and model is not rel.field.model
            and rel.parent_link
        ]

        subclasses = []
        if levels:
            levels -= 1
        for rel in rels:
            if levels or levels is None:
                for subclass in self._get_subclasses_recurse(
                        rel.field.model, levels=levels):
                    subclasses.append(
                        rel.get_accessor_name() + LOOKUP_SEP + subclass)
            subclasses.append(rel.get_accessor_name())
        return subclasses
def _get_subclasses_recurse ( self , model , levels = None ) : related_objects = [ f for f in model . _meta . get_fields ( ) if isinstance ( f , OneToOneRel ) ] rels = [ rel for rel in related_objects if isinstance ( rel . field , OneToOneField ) and issubclass ( rel . field . model , model ) and model is not rel . field . model and rel . parent_link ] subclasses = [ ] if levels : levels -= 1 for rel in rels : if levels or levels is None : for subclass in self . _get_subclasses_recurse ( rel . field . model , levels = levels ) : subclasses . append ( rel . get_accessor_name ( ) + LOOKUP_SEP + subclass ) subclasses . append ( rel . get_accessor_name ( ) ) return subclasses