Opened 19 years ago

Closed 18 years ago

Last modified 17 years ago

#317 closed defect (fixed)

[Patch] slugify delimits words by hyphens, but its validator doesn't like them

Reported by: hugo <gb@…> 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)

slug.patch (2.5 KB ) - added by sune.kirkeby@… 19 years ago.
Patch to change URLify.js, and add a separate validator for slugs.

Download all attachments as: .zip

Change History (12)

comment:1 by Manuzhai, 19 years ago

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.

by sune.kirkeby@…, 19 years ago

Attachment: slug.patch added

Patch to change URLify.js, and add a separate validator for slugs.

comment:2 by sune.kirkeby@…, 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 garthk, 19 years ago

Keywords: slugs slug slugify validation added
Summary: [patch] slugify should delimit words by hyphensslugify 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 Manuzhai, 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 sune.kirkeby@…, 18 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 Jacob, 18 years ago

milestone: Version 1.0
Owner: changed from Adrian Holovaty to Jacob
Status: newassigned

comment:7 by Adrian Holovaty, 18 years ago

Resolution: fixed
Status: assignedclosed

(In [968]) Fixed #317 -- SlugField now accepts hyphens. Thanks, Sune

comment:8 by hugo, 18 years ago

Resolution: fixed
Status: closedreopened

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:9 by Adrian Holovaty, 18 years ago

Resolution: fixed
Status: reopenedclosed

This was fixed in [1017].

comment:10 by (none), 17 years ago

milestone: Version 1.0

Milestone Version 1.0 deleted

in reply to:  description comment:11 by anonymous, 17 years ago

Component: Admin interfaceGeneric views
Has patch: set
Triage Stage: UnreviewedAccepted
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.

Note: See TracTickets for help on using tickets.
Back to Top