def is_reverse_o2o(field):
    return field.is_relation and field.one_to_one and not field.concrete
A little helper to check if the given field is reverse-o2o. The field is
dataset/ETHPy150Open django/django/django/db/models/sql/query.py/is_reverse_o2o