diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt index 1350bd6af7..1c885fa472 100644 --- a/docs/ref/utils.txt +++ b/docs/ref/utils.txt @@ -16,10 +16,10 @@ the :ref:`internal release deprecation policy \d+)/$``, e.g. ``persona/5/``. -.. function:: slugify(allow_unicode=False) +.. function:: slugify(value, allow_unicode=False) - Converts to ASCII if ``allow_unicode`` is ``False`` (default). Converts spaces to - hyphens. Removes characters that aren't alphanumerics, underscores, or - hyphens. Converts to lowercase. Also strips leading and trailing whitespace. + Converts a string to a URL slug by: + + #. Converting to ASCII if ``allow_unicode`` is ``False`` (the default). + #. Removing characters that aren't alphanumerics, underscores, hyphens, or + whitespace. + #. Removing leading and trailing whitespace. + #. Converting to lowercase. + #. Replacing any whitespace or repeated dashes with single dashes. For example:: - slugify(value) + >>> slugify(' Joel is a slug ') + 'joel-is-a-slug' - If ``value`` is ``"Joel is a slug"``, the output will be - ``"joel-is-a-slug"``. + If you want to allow Unicode characters, pass ``allow_unicode=True``. For + example:: - You can set the ``allow_unicode`` parameter to ``True``, if you want to - allow Unicode characters:: - - slugify(value, allow_unicode=True) - - If ``value`` is ``"你好 World"``, the output will be ``"你好-world"``. + >>> slugify('你好 World', allow_unicode=True) + '你好-world' .. _time-zone-selection-functions: