def get_model_at_related_field(model, attr):

    try:
        field, _, direct, m2m = model._meta.get_field_by_name(attr)
    except FieldDoesNotExist:
        raise

    if not direct:
        if hasattr(field, 'related_model'):  # Reverse relationship
            # -- Django >=1.8 mode
            return field.related_model
        elif hasattr(field, "model"):
            # -- Django <1.8 mode
            return field.model

    if hasattr(field, 'rel') and field.rel:  # Forward/m2m relationship
        return field.rel.to

    if hasattr(field, 'field'):  # Forward GenericForeignKey in Django 1.6+
        return field.field.rel.to

    raise ValueError("{0}.{1} ({2}) is not a relationship field.".format(model.__name__, attr,
                                                                         field.__class__.__name__))
Wait for lfunc to be True
dataset/ETHPy150Open pivotal-energy-solutions/django-datatable-view/datatableview/utils.py/get_model_at_related_field--crossover with--dataset/ETHPy150Open saltstack/salt/salt/modules/bcache.py/_wait