[py3] Fixed slugify filter
This commit is contained in:
parent
5d01f3caea
commit
2d2dca2d8e
|
@ -234,8 +234,8 @@ def slugify(value):
|
||||||
Normalizes string, converts to lowercase, removes non-alpha characters,
|
Normalizes string, converts to lowercase, removes non-alpha characters,
|
||||||
and converts spaces to hyphens.
|
and converts spaces to hyphens.
|
||||||
"""
|
"""
|
||||||
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
|
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode()
|
||||||
value = six.text_type(re.sub('[^\w\s-]', '', value).strip().lower())
|
value = re.sub('[^\w\s-]', '', value).strip().lower()
|
||||||
return mark_safe(re.sub('[-\s]+', '-', value))
|
return mark_safe(re.sub('[-\s]+', '-', value))
|
||||||
|
|
||||||
@register.filter(is_safe=True)
|
@register.filter(is_safe=True)
|
||||||
|
|
Loading…
Reference in New Issue