Django Autoslug

1.9.9 · active · verified Wed Apr 15

Django-autoslug is a reusable Django library that provides an improved slug field which can automatically: populate itself from another field, preserve uniqueness of the value, and use custom slugify() functions for better internationalization (i18n). The current version is 1.9.9. It maintains an active release cadence with regular updates and compatibility improvements for newer Django and Python versions.

Warnings

Install

Imports

Quickstart

Define an `AutoSlugField` in your Django model, specifying the `populate_from` attribute to indicate which field should be used to generate the slug. Ensure `unique=True` if you require unique slugs.

from django.db import models
from autoslug import AutoSlugField

class Article(models.Model):
    title = models.CharField(max_length=200)
    # The slug will be populated from the 'title' field
    slug = AutoSlugField(populate_from='title', unique=True)

    def __str__(self):
        return self.title

view raw JSON →