1
0
mirror of https://github.com/django/django.git synced 2025-04-15 04:44:37 +00:00

[py3] Fixed slugify filter

This commit is contained in:
Claude Paroz 2012-08-15 12:28:43 +02:00
parent 5d01f3caea
commit 2d2dca2d8e

View File

@ -234,8 +234,8 @@ def slugify(value):
Normalizes string, converts to lowercase, removes non-alpha characters,
and converts spaces to hyphens.
"""
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
value = six.text_type(re.sub('[^\w\s-]', '', value).strip().lower())
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode()
value = re.sub('[^\w\s-]', '', value).strip().lower()
return mark_safe(re.sub('[-\s]+', '-', value))
@register.filter(is_safe=True)