def get_remote_field(field):
    """Return the remote field for a relation.

    This is equivalent to ``rel`` prior to Django 1.9 and ``remote_field``
    in 1.9 onward.

    Args:
        field (django.db.models.Field):
            The relation field.

    Returns:
        django.db.models.Field:
        The remote field on the relation.
    """
    if hasattr(field, 'remote_field'):
        # Django >= 1.9
        return field.remote_field
    else:
        # Django < 1.9
        return field.rel