'Validate and set the new slug for `item`.'

def set_slug(self, item, new_slug, user, flush=True):

    if (not self.is_valid_slug(new_slug)):
        raise exceptions.RequestParameterInvalidException('Invalid    slug', slug=new_slug)
    if self._slug_exists(user, new_slug):
        raise exceptions.Conflict('Slug    already    exists', slug=new_slug)
    item.slug = new_slug
    if flush:
        self.session().flush()
    return item
