utils.text.slugify()

slugify(allow_unicode=False) [source]

Converts to ASCII if allow_unicode is False (default). Converts spaces to hyphens. Removes characters that aren’t alphanumerics, underscores, or hyphens. Converts to lowercase. Also strips leading and trailing whitespace.

For example:

slugify(value)

If value is "Joel is a slug", the output will be "joel-is-a-slug".

You can set the allow_unicode parameter to True, if you want to allow Unicode characters:

slugify(value, allow_unicode=True)

If value is "你好 World", the output will be "你好-world".

Changed in Django 1.9:

The allow_unicode parameter was added.

doc_Django
2016-10-09 18:40:34
Comments
Leave a Comment

Please login to continue.