From 0382ecfe020b4c51b4c01e4e9a21892771e66941 Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 26 May 2020 22:56:41 +0100 Subject: Fixed #28694 -- Made django.utils.text.slugify() strip dashes and underscores. --- docs/ref/utils.txt | 7 ++++++- docs/releases/3.2.txt | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt index dcc354e2e2..921aba5de8 100644 --- a/docs/ref/utils.txt +++ b/docs/ref/utils.txt @@ -853,8 +853,8 @@ appropriate entities. #. Converting to lowercase. #. Removing characters that aren't alphanumerics, underscores, hyphens, or whitespace. - #. Removing leading and trailing whitespace. #. Replacing any whitespace or repeated dashes with single dashes. + #. Removing leading and trailing whitespace, dashes, and underscores. For example:: @@ -867,6 +867,11 @@ appropriate entities. >>> slugify('你好 World', allow_unicode=True) '你好-world' + .. versionchanged:: 3.2 + + In older versions, leading and trailing dashes and underscores are not + removed. + .. _time-zone-selection-functions: ``django.utils.timezone`` diff --git a/docs/releases/3.2.txt b/docs/releases/3.2.txt index a869eb49cf..5436726fa4 100644 --- a/docs/releases/3.2.txt +++ b/docs/releases/3.2.txt @@ -280,6 +280,9 @@ Miscellaneous * :attr:`.ModelAdmin.prepopulated_fields` no longer strips English stop words, such as ``'a'`` or ``'an'``. +* :func:`~django.utils.text.slugify` now removes leading and trailing dashes + and underscores. + .. _deprecated-features-3.2: Features deprecated in 3.2 -- cgit v1.3