Python-slugify is an actively maintained library that generates URL-friendly slugs from strings, with robust Unicode support. It is designed to create clean, human-readable, and SEO-friendly slugs by converting text, handling special characters, and replacing spaces. The library sees regular updates, with an average release cycle of approximately 71 days.
pip install python-slugifyVerified import paths — ran on the pinned version, not inferred.
The primary `slugify` function is imported and used to convert strings into URL-friendly slugs. It supports various customization options like separators, maximum length, and preserving Unicode characters.
Ensure `pip uninstall slugify` is run if the wrong package was installed, then `pip install python-slugify`. If possible, avoid installing both packages in the same environment.
Upgrade your Python interpreter to 3.10 or newer, or pin `python-slugify` to a version compatible with your Python environment (e.g., `<7.0.0` for Python 3.6).
If GPL license is a concern, do not install `python-slugify[unidecode]`. The package works with the default `text-unidecode` which is permissively licensed.
Review and update any custom `regex_pattern` configurations to align with the new 'disallowed characters' logic.
Use `from slugify import slugify` or `import slugify` to correctly import the library.
Import the function directly using `from slugify import slugify` and then call `slugify("my string")`, or if using `import slugify`, call `slugify.slugify("my string")`.Ensure the input passed to the `slugify` function is always a string, converting other types using `str()` if needed (e.g., `slugify(str(my_number))`).