def title(value, failure_string='N/A'):
    """
    Converts a string into titlecase.
    
    Lifted from Django.
    """
    try:
        value = value.lower()
        t = re.sub("([a-z])'([A-Z])", lambda m: m.group(0).lower(), value.title())
        result = re.sub("\d([A-Z])", lambda m: m.group(0).lower(), t)
        if not result:
            return failure_string
        return result
    except:
        return failure_string