skip to navigation
skip to content

Not Logged In

django-uuslug 0.8

A Django slugify application that guarantees uniqueness and handles unicode

Latest Version: 1.0.2


A Django slugify application that guarantees uniqueness and handles unicode.
UUSlug = (``U``nique + ``U``nicode Slug)

Patches welcome:


A. Install django-uuslug:
    * _ Make sure you have python 2.6+ and can install from pypi
        1. easy_install django-uuslug
        2. pip install django-uuslug
        3. git clone
            a. cd django-uuslug
            b. run python
        4. wget
            a. unzip the downloaded file
            b. cd into django-uuslug-* directory
            c. run python

B. Test & contribute to django-uuslug: (for developers)
    * _ git clone
            a. cd into django-uuslug
            b. run python
            c. run bin/buildout -vvvvv
            d. run bin/test

Unicode Test Example
from uuslug import slugify

s = "This is a test ---"
r = slugify(s)
self.assertEquals(r, "this-is-a-test")

s = 'C\'est déjà l\'été.'
r = slugify(s)
self.assertEquals(r, "c-est-deja-lete")

s = 'Nín hǎo. Wǒ shì zhōng guó rén'
r = slugify(s)
self.assertEquals(r, "nin-hao-wo-shi-zhong-guo-ren")

s = '影師嗎'
r = slugify(s)
self.assertEquals(r, "ying-shi-ma")

Uniqueness Test Example
Override your object's save method with something like this (

from django.db import models
from uuslug import uuslug

class CoolSlug(models.Model):
    name = models.CharField(max_length=100)
    slug = models.CharField(max_length=200)

    def __unicode__(self):

    def save(self, *args, **kwargs):
        self.slug = uuslug(, instance=self)
        super(CoolSlug, self).save(*args, **kwargs)

Note: You can also specify the start number.
    self.slug = uuslug(, instance=self, start_no=2)
    # the second slug should start with "-2" instead of "-1"


name = "john"
c = CoolSlug.objects.create(name=name)
self.assertEquals(c.slug, name) # slug = "john"

c1 = CoolSlug.objects.create(name=name)
self.assertEquals(c1.slug, name+"-1") # slug = "john-1"

c1 = CoolSlug.objects.create(name=name)
self.assertEquals(c1.slug, name+"-2") # slug = "john-2"

clean up README
add more test and examples

This is inspired by a snippet from
Improved to handle unique slugs and unicode chars and packaged for easy install.
File Type Py Version Uploaded on Size
django-uuslug-0.8.tar.gz (md5) Source 2012-08-07 4KB
  • Downloads (All Versions):
  • 15 downloads in the last day
  • 283 downloads in the last week
  • 1124 downloads in the last month