Skip to content

Commit 5ed6f3f

Browse files
authored
Remove obsolete slugify dependency (#44)
Django's native slugify function used to drop non-ASCII characters, like German umlauts. However, this seems to be resolved. The behavior is now similar to https://github.com/mozilla/unicode-slugify.
1 parent 2bd9f97 commit 5ed6f3f

File tree

4 files changed

+3
-37
lines changed

4 files changed

+3
-37
lines changed

.github/workflows/ci.yml

-23
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,3 @@ jobs:
7474
- name: Run tests
7575
run: python setup.py test
7676
- run: codecov
77-
78-
extras:
79-
needs:
80-
- readme
81-
- lint
82-
runs-on: ubuntu-latest
83-
strategy:
84-
matrix:
85-
extras:
86-
- slugify
87-
88-
steps:
89-
- uses: actions/checkout@v3
90-
- uses: actions/setup-python@v4
91-
with:
92-
python-version: "3.10"
93-
- name: Install Python dependencies
94-
run: |
95-
python -m pip install --upgrade pip setuptools wheel codecov
96-
python -m pip install -e .[${{ matrix.extras }}]
97-
- name: Run tests
98-
run: python setup.py test
99-
- run: codecov

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Installation
1414

1515
.. code-block:: bash
1616
17-
pip install django-dynamic-filenames[slugify]
17+
pip install django-dynamic-filenames
1818
1919
Samples
2020
~~~~~~~

dynamic_filenames.py

+2-12
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,7 @@
33
import re
44
import uuid
55
from string import Formatter
6-
7-
8-
def slugify(value):
9-
try: # use unicode-slugify library if installed
10-
from slugify import slugify as _slugify
11-
12-
return _slugify(value, only_ascii=True)
13-
except ImportError:
14-
from django.utils.text import slugify as _slugify
15-
16-
return _slugify(value, allow_unicode=False)
6+
from django.utils.text import slugify
177

188

199
class SlugFormatter(Formatter):
@@ -24,7 +14,7 @@ def format_field(self, value, format_spec):
2414
if precision:
2515
precision = int(precision.lstrip("."))
2616
if ftype == "slug":
27-
return slugify(value)[:precision]
17+
return slugify(value, allow_unicode=False)[:precision]
2818
return super().format_field(value=value, format_spec=format_spec)
2919

3020

setup.cfg

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ tests_require =
4141

4242
[options.extras_require]
4343
slugify =
44-
unicode-slugify
4544

4645
[aliases]
4746
test = pytest

0 commit comments

Comments
 (0)