def get_lookup(field_name, versionable):
    """Returns a filtering lookup.

    If passed a versionable (which is a VersionableItem for the content object),
    it makes it so that lookup uses <grouper>__<content> form.

    :param field_name:
    :param versionable: VersionableItem or None
    """
    if versionable:
        content_name = versionable.grouper_field.remote_field.get_accessor_name()
        return "{}__{}".format(field_name, content_name)
    return field_name