This project has been archived by its maintainers, and is no longer receiving any updates.
django-slugger
Automatic slug field for your Django models.
Features
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.
Installation
pip install django-slugger
Usage
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)
Release files for django-slugger 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-slugger-1.1.2.tar.gz | 6.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_slugger-1.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.9 kB
Release files / django-slugger-1.1.2.tar.gz
| Download URL | django-slugger-1.1.2.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
634fcb6df91319b045f30abe50c6835a4fab12ade5d35616accb83fbd481e096
|
|
BLAKE2b-256 checksum How to use checksums |
1e0210e6b2fc09fd87f34b26829b839a3687479f98614220dac9f8f55505c143
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6
|
Release files / django_slugger-1.1.2-py3-none-any.whl
| Download URL | django_slugger-1.1.2-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
61059a482774945357924f1fd75f4f0028f54488d5b518d2dd527d967348237c
|
|
BLAKE2b-256 checksum How to use checksums |
131a085ef983d0d9cc01d830a39a713ac2f8ba93546ebf8ce8b3c9597ffd2982
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6
|