Ticket #4365: defaultfilters.py.patch
File defaultfilters.py.patch, 770 bytes (added by , 17 years ago) |
---|
-
django/template/defaultfilters.py
120 120 make_list = stringfilter(make_list) 121 121 122 122 def slugify(value): 123 "Converts to lowercase, removes non-alpha chars and converts spaces to hyphens" 124 value = re.sub('[^\w\s-]', '', value).strip().lower() 123 """Normalizes string, converts to lowercase, removes non-alpha chars 124 and converts spaces to hyphens.""" 125 import unicodedata 126 ascii_str = unicodedata.normalize( 'NFKD', \ 127 value.decode('utf-8', 'replace') ).encode('ascii', 'ignore') 128 value = re.sub('[^\w\s-]', '', ascii_str).strip().lower() 125 129 return re.sub('[-\s]+', '-', value) 126 130 slugify = stringfilter(slugify) 127 131