> > > Is there a canonical definition or even a reference implementation > > of a slug =3D slugify(str) function somewhere? Yeah, I could go > > grep through the sources and maybe find one? And yes, I see: > >=20 > > http://docs.djangoproject.com/en/dev/ref/models/fields/#slugfield > >=20 > > But even that is a bit ambiguous as to the treatment of underscores. > > Could you clarify what you mean by "ambiguous as to the treatment of unders= > cores"? I don't see an ambiguity, so I wonder what I'm missing.
Some places say underscores are valid, others say they removed: http://docs.djangoproject.com/en/dev/ref/templates/builtins/ slugify Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens. Also strips leading and trailing whitespace. > My understanding is that a slug is usable as a URL; that's really the synta= > x definition, and is why it is limited to "only letters, numbers, underscor= > es or hyphens." A slug is effectively an artifact of Django's birth in jour= > nalism-on-the-web, and an extraordinarily handy one. As such, it exists fo= > r practical reasons, rather than purity. Sure, I get that. It would be nice to use the same (or at least internally consistent) definition, of course. > I do indeed use the slugify() function for precisely that pattern. Exactly *which* slugify() function? Documentation reference? Import from line? > I override the model's save method, and populate the slug field prior > to allowing the save to proceed. I picked up that trick from some > other code somewhere; it isn't uncommon. Well, yeah. That's what I want to do too! :-) Any chance you can post a snippet for me? > HTH, Somewhat! Thanks, jdl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.