Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A Django field that automatically generates random slugs.

Project Description

Django field that automatically generates random slugs.


Tested with Python 2.7, 3.3+ and Django 1.4+.

Getting it

To install django-randomslugfield:

$ pip install django-randomslugfield


To enable randomslugfield in your project you need to add it to INSTALLED_APPS in your projects file:



Import RandomSlugField and use it in your model:

from django.db import models
from randomslugfield import RandomSlugField

class MyModel(models.Model):
    slug = RandomSlugField(length=7)

The length argument is required.

Advanced Usage

By default randomslugfield generates its slug using these characters:


You can optionally exclude lowercase/uppercase/digits/vowels using exclude_lower=True, exclude_upper=True, exclude_digits=True, exclude_vowels=True.

You cannot exclude all characters.


class MyModel(models.Model):
    slug = RandomSlugField(length=7, exclude_lower=True)

The total number of unique slugs is determined by characters^length.

62^9 = 13,537,086,546,263,552 possible slugs
62^8 = 218,340,105,584,896 possible slugs
62^7 = 3,521,614,606,208 possible slugs
62^6 = 56,800,235,584 possible slugs
62^5 = 916,132,832 possible slugs
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date (9.2 kB) Copy SHA256 Checksum SHA256 Source Aug 2, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting