def slugify2(value):
"""
Normalizes string, converts to lowercase, removes non-alpha characters,
and converts spaces to hyphens.
It is similar to built-in :filter:`slugify` but it also handles special characters in variety of languages
so that they are not simply removed but properly transliterated/downcoded.
"""
try:
value = unicodedata.normalize('NFC', value)
value = downcode(value)
value = unicodedata.normalize('NFD', value).encode('ascii', 'ignore')
value = unicode(re.sub('[^\w\s-]', '', value).strip().lower())
return safestring.mark_safe(re.sub('[-\s]+', '-', value))
except:
if settings.TEMPLATE_DEBUG:
raise
else:
return u''
评论列表
文章目录