colour.utilities.slugify#

colour.utilities.slugify(object_: Any, allow_unicode: bool = False) str[source]#

Generate a SEO friendly and human-readable slug from given object.

Convert to ASCII if allow_unicode is False. Convert spaces or repeated dashes to single dashes. Remove characters that aren’t alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip leading and trailing whitespace, dashes, and underscores.

Parameters:
  • object – Object to convert to a slug.

  • allow_unicode (bool) – Whether to allow unicode characters in the generated slug.

  • object_ (Any) –

Returns:

Generated slug.

Return type:

str

References

[DjangoSFoundation22]

Examples

>>> slugify(" Jack & Jill like numbers 1,2,3 and 4 and silly characters ?%.$!/")
'jack-jill-like-numbers-123-and-4-and-silly-characters'