Skip to main content

slugify

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.

def slugify(
value: Any,
allow_unicode: boolean = False
) - > string

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

NameTypeDescription
valueAnyThe input string or lazy text object to be converted into a slug
allow_unicodeboolean = FalseWhether to allow non-ASCII characters in the resulting slug; if False, characters are converted to ASCII or removed

Returns

TypeDescription
stringThe processed string transformed into a URL-friendly slug format