django-randomslugfield 0.3.0

A Django field that automatically generates random slugs.
<object data="https://pypip.in/version/django-randomslugfield/badge.svg" type="image/svg+xml">https://pypip.in/version/django-randomslugfield/badge.svg</object> <object data="https://pypip.in/download/django-randomslugfield/badge.svg" type="image/svg+xml">https://pypip.in/download/django-randomslugfield/badge.svg</object>

Django field that automatically generates random slugs.

e.g. example.com/kEwD58P

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

Getting it

To install django-randomslugfield:

$ pip install django-randomslugfield

Install

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

INSTALLED_APPS = (
    ...
    'randomslugfield',
    ...
)

Usage

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:

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

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.

Example:

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
MIT

Author

Mike Johnson

Pip

django-randomslugfield==0.3.0

Classifiers

  • Programming Language :: Python :: 3.4
  • Programming Language :: Python :: 3.3
  • Programming Language :: Python :: 2.7
  • Programming Language :: Python
  • Operating System :: OS Independent
  • License :: OSI Approved :: MIT License
  • Intended Audience :: Developers
  • Framework :: Django
  • Environment :: Web Environment
  • Development Status :: 5 - Production/Stable
File Type Python Version Uploaded On Downloads
django-randomslugfield-0.3.0.zip Source Aug. 2, 2014 625
Version Release Date
0.3.0 Aug. 2, 2014
0.2.1 Dec. 5, 2013
0.2.0 Dec. 5, 2013
0.1.1 Oct. 14, 2013
0.1.0 Sept. 8, 2013
Date Package Version Action
Nov. 4, 2014, 1:40 p.m. django-randomslugfield 0.2.0 Release Created
Nov. 4, 2014, 1:40 p.m. django-randomslugfield 0.2.1 Release Created
Nov. 4, 2014, 1:40 p.m. django-randomslugfield 0.3.0 Release Created
Nov. 4, 2014, 1:40 p.m. django-randomslugfield 0.1.1 Release Created
Nov. 4, 2014, 1:40 p.m. django-randomslugfield 0.1.0 Release Created
Nov. 4, 2014, 1:40 p.m. django-randomslugfield Package Created