#31511: Allow stopwords in slugs generated by ModelAdmin.prepopulated_fields
-------------------------------------+-------------------------------------
Reporter: Andy | Owner: Scott Cranfill
Chosak |
Type: | Status: assigned
Cleanup/optimization |
Component: | Version: master
contrib.admin | Keywords: urlify, slugify,
Severity: Normal | slug
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
Automatic slug generation in ModelAdmin via
[https://docs.djangoproject.com/en/3.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin.prepopulated_fields
prepopulated_fields] uses a
[https://github.com/django/django/blob/b2bd08bb7a912a1504f5fb5018f5317e6b5423cd/django/contrib/admin/static/admin/js/urlify.js
urlify.js] file which, among other behaviors,
[https://github.com/django/django/blob/b2bd08bb7a912a1504f5fb5018f5317e6b5423cd/django/contrib/admin/static/admin/js/urlify.js#L168-L176
removes certain stop words from the slug]. For example, a string like "To
be or not to be, that is the question" will generate a slug "be-or-not-be-
question", not "to-be-or-not-to-be-that-is-the-question" as one might
expect.
For reference, the current list is: a, an, as, at, before, but, by, for,
from, is, in, into, like, of, off, on, onto, per, since, than, the, this,
that, to, up, via, with.
The current list of stopwords being removed seems to have been the same
since at least 2005 (the earliest code I can find including this logic).
Some of these words feel a little unexpected, for example “before” and
“since”. It seems likely that stop word removal was introduced for SEO
purposes, but this no longer seems to be a modern best practice. I propose
removing this behavior so that these words are no longer stripped from
slugs generated via prepopulated_fields.
I posted this proposal to https://groups.google.com/forum/#!topic/django-
developers/9ayU7fTuuAM and received one supportive reply from Adam
Johnson. @Scotchester and I have collaborated on a patch.
(#30538 mentions this behavior as part of a more general comparison
between urlify.js and Python slugify. It was closed as wontfix due to
reasons of backwards compatibility. This ticket specifically addresses
stopword removal in the JS code only, not any other differences in
behavior between these two methods.)
--
Ticket URL: <https://code.djangoproject.com/ticket/31511>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.6b1e0fbe1ec62328eb24ddd5fbb0f188%40djangoproject.com.