#317 closed defect (fixed)
[Patch] slugify delimits words by hyphens, but its validator doesn't like them
Reported by: | Owned by: | Jacob | |
---|---|---|---|
Component: | Generic views | Version: | 0.95 |
Severity: | normal | Keywords: | slugs slug slugify validation |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
. words separated by underscores ("_") or hyphens ("-") in URLs. Google will treat "keyword-phrase" as "keyword phrase" and "keyword_phrase" as "keywordphrase. - google handles _ and - differently, where the - form usually is what the user needs. So the slugify code should just handle multi-word sentences by delimiting the slugified words by hyphens.
Attachments (1)
Change History (12)
comment:1 by , 19 years ago
by , 19 years ago
Attachment: | slug.patch added |
---|
Patch to change URLify.js, and add a separate validator for slugs.
comment:2 by , 19 years ago
Summary: | slugify should delimit words by hyphens → [patch] slugify should delimit words by hyphens |
---|
Just added a patch which updates the prepopulating javascript to replace spaces with dashes, and add a separate validator (isSlug) for slugs, which accepts dashes in slugs.
Please, could this (or something like it) get committed? As the OP said, dashes and underscores are different in URLs, so they should both be allowed in slugs.
comment:3 by , 19 years ago
Keywords: | slugs slug slugify validation added |
---|---|
Summary: | [patch] slugify should delimit words by hyphens → slugify delimits words by hyphens, but its validator doesn't like them |
I'm seeing dashes in my SlugFields after using django.core.defaultfilters.slugify in my _pre_save, but when I try to edit one of the postings afterward in the administration interface I get validation errors.
comment:4 by , 19 years ago
Summary: | slugify delimits words by hyphens, but its validator doesn't like them → [Patch] slugify delimits words by hyphens, but its validator doesn't like them |
---|
Hmm, isn't the regex just wrong?
Also, adding [Patch] to summary to gain inclusion in {12}.
comment:5 by , 19 years ago
Hmm, isn't the regex just wrong?
Which regex? I am running the patch I attached, and it works for me.
comment:6 by , 19 years ago
milestone: | → Version 1.0 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:7 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:8 by , 19 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
urlify still delimits words by _ instead of -. I think we definitely should switch to delimiting by hyphens, as that's much more google friendly than underscores.
comment:11 by , 18 years ago
Component: | Admin interface → Generic views |
---|---|
Has patch: | set |
Triage Stage: | Unreviewed → Accepted |
Version: | → 0.95 |
Replying to hugo <gb@bofh.ms>:
. words separated by underscores ("_") or hyphens ("-") in URLs. Google will treat "keyword-phrase" as "keyword phrase" and "keyword_phrase" as "keywordphrase. - google handles _ and - differently, where the - form usually is what the user needs. So the slugify code should just handle multi-word sentences by delimiting the slugified words by hyphens.
I agree, and I have talked about this with jacobkm before. I also have patches, but they're kinda trivial. Just remember that you need to change both the validator and the prepopulating javascript.