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 i18n.
The field is highly configurable.
Requirements
Python 2.7, 3.5 or PyPy.
Django 1.7.10 or higher.
It may be possible to successfully use django-autoslug in other environments but they are not tested.
Examples
A simple example:
from django.db.models import CharField, Model
from autoslug import AutoSlugField
class Article(Model):
title = CharField(max_length=200)
slug = AutoSlugField(populate_from='title')
More complex example:
from django.db.models import CharField, DateField, ForeignKey, Model
from django.contrib.auth.models import User
from autoslug import AutoSlugField
class Article(Model):
title = CharField(max_length=200)
pub_date = DateField(auto_now_add=True)
author = ForeignKey(User)
slug = AutoSlugField(populate_from=lambda instance: instance.title,
unique_with=['author__name', 'pub_date__month'],
slugify=lambda value: value.replace(' ','-'))
Documentation
See the complete documentation on ReadTheDocs. It is built automatically for the latest version.
Community
This application was initially created by Andy Mikhailenko and then improved by other developers. They are listed in AUTHORS.rst.
Please feel free to file issues and/or submit patches.
See CONTRIBUTING.rst for hints related to the preferred workflow.
Licensing
Django-autoslug is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
Django-autoslug is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program; see the file COPYING.LESSER. If not, see GNU licenses.
Release files for lc-django-autoslug 1.9.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lc-django-autoslug-1.9.5.tar.gz | 21.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lc_django_autoslug-1.9.5-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size:36.8 kB
Release files / lc-django-autoslug-1.9.5.tar.gz
| Download URL | lc-django-autoslug-1.9.5.tar.gz |
|---|---|
| Size | 21.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d73bc31022b3834e6aff93ecde138f8e4c7e3ae7838060c544fc135334eb93d
|
|
BLAKE2b-256 checksum How to use checksums |
38029a66a0d29dba232d9dbaf12a8dca79da2511991fe43c437cf29eae5cbb03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
|
Release files / lc_django_autoslug-1.9.5-py2.py3-none-any.whl
| Download URL | lc_django_autoslug-1.9.5-py2.py3-none-any.whl |
|---|---|
| Size | 15.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f82566f3436e2f86621f61c62d00051ae10e3bc4222a04c3df03148cfcd9de03
|
|
BLAKE2b-256 checksum How to use checksums |
588fc98aa68dcc283779484d5293011ef9a5a4160f902ec5c06a7f823dde894a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
|