import re


def filename_convert(value):
    """
    removes non-alpha or non-number characters, and converts underscores, hyphens and spaces to a single underscore.

    Adapt from stackoverflow according to https://www.djangoproject.com/
    The function is called by fill_filename() function in this user_helper program.
    """
    # delete all non-word, non-whitespace, and not _ or - characters.
    value = re.sub('[^\w\s_-]', '', value).strip()
    # convert all -, _, whitespace characters into one single underscore.
    value = re.sub('[-_\s]+', '_', value)
    return value