diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py index 9ae5c1f735..9f46770c85 100644 --- a/django/template/defaultfilters.py +++ b/django/template/defaultfilters.py @@ -232,9 +232,9 @@ def make_list(value): @stringfilter def slugify(value): """ - Converts to lowercase, removes non-word characters (alphanumerics and - underscores) and converts spaces to hyphens. Also strips leading and - trailing whitespace. + Converts to ASCII. Converts spaces to hyphens. Removes characters that + aren't alphanumerics, underscores, or hyphens. Converts to lowercase. + Also strips leading and trailing whitespace. """ return _slugify(value) diff --git a/django/utils/text.py b/django/utils/text.py index df6e1d0c46..34535d6455 100644 --- a/django/utils/text.py +++ b/django/utils/text.py @@ -435,9 +435,9 @@ unescape_string_literal = allow_lazy(unescape_string_literal) def slugify(value): """ - Converts to lowercase, removes non-word characters (alphanumerics and - underscores) and converts spaces to hyphens. Also strips leading and - trailing whitespace. + Converts to ASCII. Converts spaces to hyphens. Removes characters that + aren't alphanumerics, underscores, or hyphens. Converts to lowercase. + Also strips leading and trailing whitespace. """ value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii') value = re.sub('[^\w\s-]', '', value).strip().lower() diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index 7671d59291..e2a8da0fd7 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -2036,9 +2036,9 @@ If ``some_list`` is ``['a', 'b', 'c']``, the output will be ``['a', 'b']``. slugify ^^^^^^^ -Converts to lowercase, removes non-word characters (alphanumerics and -underscores) and converts spaces to hyphens. Also strips leading and trailing -whitespace. +Converts to ASCII. Converts spaces to hyphens. Removes characters that aren't +alphanumerics, underscores, or hyphens. Converts to lowercase. Also strips +leading and trailing whitespace. For example:: diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt index 1b16566d3c..1ecb8eed6b 100644 --- a/docs/ref/utils.txt +++ b/docs/ref/utils.txt @@ -817,9 +817,9 @@ appropriate entities. .. function:: slugify - Converts to lowercase, removes non-word characters (alphanumerics and - underscores) and converts spaces to hyphens. Also strips leading and - trailing whitespace. + Converts to ASCII. Converts spaces to hyphens. Removes characters that + aren't alphanumerics, underscores, or hyphens. Converts to lowercase. Also + strips leading and trailing whitespace. For example::