Skip to content

Commit

Permalink
Remove obsolete slugify dependency (#44)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
amureki authored Oct 5, 2022
1 parent 2bd9f97 commit 5ed6f3f
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 37 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,3 @@ jobs:
- name: Run tests
run: python setup.py test
- run: codecov

extras:
needs:
- readme
- lint
runs-on: ubuntu-latest
strategy:
matrix:
extras:
- slugify

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools wheel codecov
python -m pip install -e .[${{ matrix.extras }}]
- name: Run tests
run: python setup.py test
- run: codecov
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Installation

.. code-block:: bash
pip install django-dynamic-filenames[slugify]
pip install django-dynamic-filenames
Samples
~~~~~~~
Expand Down
14 changes: 2 additions & 12 deletions dynamic_filenames.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,7 @@
import re
import uuid
from string import Formatter


def slugify(value):
try: # use unicode-slugify library if installed
from slugify import slugify as _slugify

return _slugify(value, only_ascii=True)
except ImportError:
from django.utils.text import slugify as _slugify

return _slugify(value, allow_unicode=False)
from django.utils.text import slugify


class SlugFormatter(Formatter):
Expand All @@ -24,7 +14,7 @@ def format_field(self, value, format_spec):
if precision:
precision = int(precision.lstrip("."))
if ftype == "slug":
return slugify(value)[:precision]
return slugify(value, allow_unicode=False)[:precision]
return super().format_field(value=value, format_spec=format_spec)


Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ tests_require =

[options.extras_require]
slugify =
unicode-slugify

[aliases]
test = pytest
Expand Down

0 comments on commit 5ed6f3f

Please sign in to comment.