

def get_foreign_key(self, source, dest, field=None):
    if (isinstance(source, SelectQuery) or isinstance(dest, SelectQuery)):
        return (None, None)
    fk_field = source._meta.rel_for_model(dest, field)
    if (fk_field is not None):
        return (fk_field, False)
    reverse_rel = source._meta.reverse_rel_for_model(dest, field)
    if (reverse_rel is not None):
        return (reverse_rel, True)
    return (None, None)

dataset/ETHPy150Open coleifer/peewee/peewee.py Join.get_foreign_key/original