def lookup_dunder_prop(obj, props, multi=False):
    """
    Take an obj and lookup the value of a related attribute
    using __ notation.

    For example if Obj.a.b.c == "foo" then lookup_dunder (Obj, "a__b__c") == "foo"
    """
    try:
        if "__" in props:
            head, tail = props.split("__", 1)
            obj = getattr(obj, head)
            return lookup_dunder_prop(obj, tail, multi=multi)
        if multi:
            return [getattr(o, props) for o in obj.all()]
        return getattr(obj, props)
    except AttributeError:
        return None