[py3] Made 212b9826bd Python 3-friendly

This commit is contained in:
Aymeric Augustin 2012-08-18 17:47:21 +02:00
parent de3ad8bb2d
commit afc1bd7ab8
3 changed files with 11 additions and 11 deletions

View file

@ -391,7 +391,7 @@ def slugify(value):
underscores) and converts spaces to hyphens. Also strips leading and
trailing whitespace.
"""
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
value = unicode(re.sub('[^\w\s-]', '', value).strip().lower())
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
value = re.sub('[^\w\s-]', '', value).strip().lower()
return mark_safe(re.sub('[-\s]+', '-', value))
slugify = allow_lazy(slugify, unicode)
slugify = allow_lazy(slugify, six.text_type)