django-slugify-processor
Custom slug processors for Django's
slugify().
Why
Django's slugifier is intentionally generic. That means terms such as C++ and
C# both collapse to c, which can produce duplicate or unhelpful slugs.
django-slugify-processor lets a project run its own small processors before
Django performs the final slugification step.
With no SLUGIFY_PROCESSORS setting, the package behaves like Django's
slugify().
Install
$ python -m pip install django-slugify-processor
$ uv add django-slugify-processor
Configure
Create a processor that accepts a string and returns a string:
def slugify_programming_languages(value: str) -> str:
return value.replace("C++", "Cpp").replace("C#", "CSharp")
Register the processor's import string in Django settings:
SLUGIFY_PROCESSORS = [
"myapp.slugify_processors.slugify_programming_languages",
]
Processors run in list order. The result then passes through Django's own
slugify(), including its allow_unicode handling.
Use
Use the Python helper anywhere you would use Django's slugifier:
from django_slugify_processor.text import slugify
slugify("C++ Programming") # "cpp-programming"
Load the template filter in a template that needs the same pipeline:
{% load slugify_processor %}
{{ "C++ Programming"|slugify }}
For projects that want every template to use this filter, install it as a template builtin:
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"OPTIONS": {
"builtins": [
"django_slugify_processor.templatetags.slugify_processor",
],
},
},
]
Model-field packages usually accept a slugify callback. For django-extensions:
from django.db import models
from django_extensions.db.fields import AutoSlugField
from django_slugify_processor.text import slugify
class Article(models.Model):
title = models.CharField(max_length=255)
slug = AutoSlugField(populate_from="title", slugify_function=slugify)
For django-autoslug, pass the same function to its slugify option.
Links
- Documentation: https://django-slugify-processor.git-pull.com
- API reference: https://django-slugify-processor.git-pull.com/api.html
- Changelog: https://django-slugify-processor.git-pull.com/history.html
- Source: https://github.com/tony/django-slugify-processor
- Issues: https://github.com/tony/django-slugify-processor/issues
- PyPI: https://pypi.org/project/django-slugify-processor/
Development
$ git clone https://github.com/tony/django-slugify-processor.git
$ cd django-slugify-processor
$ uv sync --all-extras --dev
$ just test
Metadata
Release files for django-slugify-processor 1.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_slugify_processor-1.11.0.tar.gz | 175.5 kB | Without provenance | Details for django_slugify_processor-1.11.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_slugify_processor-1.11.0-py3-none-any.whl | Python 3 | none | any | Details for django_slugify_processor-1.11.0-py3-none-any.whl |
Total release size: 182.1 kB
Release files / django_slugify_processor-1.11.0.tar.gz
| Download URL | django_slugify_processor-1.11.0.tar.gz |
|---|---|
| Size | 175.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d05bc374037808255763059414fef8a5d1fc4ff4345387a0b8a2a36097228fa2
|
|
BLAKE2b-256 checksum How to use checksums |
50fa99667f2dd52cceaa54f391de985b09bd0c696927e6233396be27537bc345
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / django_slugify_processor-1.11.0-py3-none-any.whl
| Download URL | django_slugify_processor-1.11.0-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10d953c4f97db128478dfc333c70d2a4c5e9d5f43c9fab18ec628454edae3310
|
|
BLAKE2b-256 checksum How to use checksums |
655fa78d2cb9680a10dc9f5f7f0a5aca44b64590aa28d5935dbcdcb3d598b80d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for django-slugify-processor 1.11.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.