Django

Code

Ticket #317 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

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

Reported by: hugo <gb@bofh.ms> Assigned to: jacob
Milestone: Component: Generic views
Version: 0.95 Keywords: slugs slug slugify validation
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

slug.patch (2.5 kB) - added by sune.kirkeby@gmail.com on 09/06/05 14:02:09.
Patch to change URLify.js, and add a separate validator for slugs.

Change History

08/14/05 10:38:44 changed by Manuzhai

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.

09/06/05 14:02:09 changed by sune.kirkeby@gmail.com

  • attachment slug.patch added.

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

09/06/05 14:04:55 changed by sune.kirkeby@gmail.com

  • summary changed from slugify should delimit words by hyphens to [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.

09/08/05 07:53:21 changed by garthk

  • keywords set to slugs slug slugify validation.
  • summary changed from [patch] slugify should delimit words by hyphens to 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.

09/08/05 09:35:26 changed by Manuzhai

  • summary changed from slugify delimits words by hyphens, but its validator doesn't like them to [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}.

09/23/05 04:00:40 changed by sune.kirkeby@gmail.com

Hmm, isn't the regex just wrong?

Which regex? I am running the patch I attached, and it works for me.

09/25/05 17:30:44 changed by jacob

  • owner changed from adrian to jacob.
  • status changed from new to assigned.
  • milestone set to Version 1.0.

10/19/05 23:20:53 changed by adrian

  • status changed from assigned to closed.
  • resolution set to fixed.

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

10/20/05 09:18:37 changed by hugo

  • status changed from closed to reopened.
  • resolution deleted.

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.

11/20/05 16:32:04 changed by adrian

  • status changed from reopened to closed.
  • resolution set to fixed.

This was fixed in [1017].

01/17/07 16:12:17 changed by

  • milestone deleted.

Milestone Version 1.0 deleted

(in reply to: ↑ description ) 02/26/07 05:42:12 changed by anonymous

  • has_patch set to 1.
  • version set to 0.95.
  • component changed from Admin interface to Generic views.
  • stage changed from Unreviewed to Accepted.

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.


Add/Change #317 ([Patch] slugify delimits words by hyphens, but its validator doesn't like them)




Change Properties
Action