slugify (Legacy Python 2)

0.0.1 · abandoned · verified Thu Apr 16

Slugify (version 0.0.1) is a legacy Python library for generating URL-friendly 'slugs' from strings, primarily for Latin-based scripts. Inspired by Django's `slugify` template filter, it provides a Python function and a command-line tool. The library is considered abandoned and only officially supports Python 2.

Common errors

Warnings

Install

Imports

Quickstart

A simple example demonstrating the use of the `slugify` function. Note that this library is Python 2 only. Running it in Python 3 will result in errors related to the `unicode()` function.

import sys
# This library is for Python 2. Running in Python 3 will cause a NameError.
# To test, ensure you are in a Python 2 environment.
if sys.version_info.major == 2:
    from slugify import slugify
    text_to_slug = u"Hello World! This is a Test 123"
    slugged_text = slugify(text_to_slug)
    print("Original:", text_to_slug)
    print("Slugged:", slugged_text)
else:
    print("This quickstart requires Python 2. Current Python version is", sys.version)

view raw JSON →