Skip to main content

A Unicode slug that is also guaranteed to be unique

Project description


A custom slug app for Django, that guarantees Double (U)s for (Uniqueness & Unicode handling)

Most of the code is originally by snippet
Improved slightly to handle unique slugs and unicode chars and packaged by Val L33.

Patches welcome:


If you want a worry free slug-er, then this is for you.
It handles unicode and it produces unique slugs.

Here what you need to do:
1. Install (via source code on github) or (pip install django-uuslug) ... etc.
2. Then import it like: from uuslug import uuslug as slugify

That's it.

Unicode Test Example

from uuslug import uuslug as 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-l-ete")

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 as slugify

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 = slugify(, instance=self)
super(CoolSlug, self).save(*args, **kwargs)


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

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

the slug for the first object would be "john", while the second object's slug
would be "john-1".

clean up README

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-uuslug-0.5.tar.gz (3.6 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page