#23558 closed Cleanup/optimization (fixed)
document slugify limitations
Reported by: | Mikhail Korobov | Owned by: | David Hoffman |
---|---|---|---|
Component: | Documentation | Version: | 1.7 |
Severity: | Normal | Keywords: | |
Cc: | mmitar@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Currently slugify docs say:
slugify Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens. Also strips leading and trailing whitespace.
In Python 3:
>>> 'вася'.isalnum() >>> True
but slugify doesn't work like documented for such strings. Isn't it a bug if something doesn't work as documented?
https://code.djangoproject.com/ticket/8391 was closed as wontfix. If there is no intention to make slugify work better it should be documented when it works and when people should find alternative solutions.
Change History (12)
comment:1 by , 10 years ago
Cc: | added |
---|
comment:2 by , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Uncategorized → Cleanup/optimization |
comment:4 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 10 years ago
Has patch: | set |
---|
Pull request: https://github.com/django/django/pull/3349
comment:6 by , 10 years ago
I created a new pull request based on the feedback to my previous one: https://github.com/django/django/pull/3357
comment:7 by , 10 years ago
The problem is, it's not *just* non-ASCII alphanumerics removed either so the suggested description is still incorrect:
Python 3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from django.utils.text import slugify >>> slugify('Māori') 'maori'
I think if the wording is to be improved, the initial process of trying to "ASCIIify" the unicode characters as the first step also needs to be explicitly documented too.
comment:8 by , 10 years ago
Ah, good point.
I have updated with another pull request: https://github.com/django/django/pull/3358
comment:9 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:11 by , 10 years ago
Is this the new documentation?
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.
Where can I find out which alphanumerics are deleted, and which alphanumerics are converted to ASCII?
s/alphanumerics/ASCII alphanumerics/
should do the job :-)More seriously, let's take this opportunity to expand a bit the documentation and point to unicode-slugify -- which produces unicode slugs, while django produces ASCII slugs.