summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/text.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/django/utils/text.py b/django/utils/text.py
index cb39110b83..4d77ce7f41 100644
--- a/django/utils/text.py
+++ b/django/utils/text.py
@@ -396,15 +396,15 @@ def slugify(value, allow_unicode=False):
Convert to ASCII if 'allow_unicode' is False. Convert spaces or repeated
dashes to single dashes. Remove characters that aren't alphanumerics,
underscores, or hyphens. Convert to lowercase. Also strip leading and
- trailing whitespace.
+ trailing whitespace, dashes, and underscores.
"""
value = str(value)
if allow_unicode:
value = unicodedata.normalize('NFKC', value)
else:
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
- value = re.sub(r'[^\w\s-]', '', value.lower()).strip()
- return re.sub(r'[-\s]+', '-', value)
+ value = re.sub(r'[^\w\s-]', '', value.lower())
+ return re.sub(r'[-\s]+', '-', value).strip('-_')
def camel_case_to_spaces(value):