Turn name into a slug suitable for an image file name

def slugify(self, name):
        """ Turn name into a slug suitable for an image file name """
        slug = ''
        last = ''
        for char in name.replace('#', '').lower().strip():
            if not char.isalnum():
                char = '_'

            if last == '_' and char == '_':
                continue

            slug += char
            last = char

        return slug