def get_field_value(obj, field_accessor):
    """Returns value for the given field for a given object. Follow ForeignKey
    relations specified by the __ notation."""
    for token in field_accessor.split('__'):
        obj = getattr(obj, token.strip())
    return obj