def get_rel_target_field(field):
    """Return the target field for a field's relation.

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

    Returns:
        django.db.models.Field:
        The field on the other end of the relation.
    """
    if hasattr(field, 'target_field'):
        # Django >= 1.7
        return field.target_field
    else:
        # Django < 1.7
        return field.related_field