Skip to main content
Help us improve Python packaging – donate today!

Automatic slug field for Django.

Project Description

build status code coverage pypi version license python versions django versions

Automatic slug field for your Django models.


  • One query to rule them all. No database spam on model save.
  • Supports all standard “unique_for” field attributes like unique_for_date.
  • Supports model meta unique_together.
  • Supports custom “slugify” functions.

How it works

django-slugger provides AutoSlugField which value is automatically generated if it is not filled manually. If the field has any “uniqueness” constraint (unique=True, for example), numerical suffix will be used if necessary to prevent constraint violation.

If generated slug exceeds field max_length, slug value will be cut to fit in. This does not apply to suffixed slugs. Increase max_length attribute value or use custom slug template if you need more space to ensure slug uniqueness.


pip install django-slugger


from slugger import AutoSlugField

class AutoSlugModel(models.Model):
    title = models.CharField(max_length=255)
    slug = AutoSlugField(populate_from='title')

Custom slug template

By default, django-slugger will use Django slugify function (combined with unidecode to handle non-ASCII characters). To use your own function, specify it in slugify argument.

def custom_slugify(value):
    return 'custom-%s' % value

class CustomAutoSlugModel(models.Model):
    title = models.CharField(max_length=255)
    slug = AutoSlugField(populate_from='title', slugify=custom_slugify)


slugify argument must be top-level named function.

Release history Release notifications

This version
History Node


History Node


History Node


History Node


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
django_slugger-1.0.4-py3-none-any.whl (6.9 kB) Copy SHA256 hash SHA256 Wheel py3 Oct 18, 2017
django-slugger-1.0.4.tar.gz (6.8 kB) Copy SHA256 hash SHA256 Source None Oct 18, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page