slug that has a dash at the end initially is changed with next model save
fuzzylogic2000 opened this issue · comments
When the field to populate the slug from is a long string (>50) with a dash, underscore or blank at the 50th position, the initial slug will end with a dash or underscore. With the first model save after the initial one, the dash is removed.
This was introduced by a change in Django's slugify with version 3.
django/django@0382ecf
Because the slugify is used before the slug is cropped, the dash or underscore at the end is initially saved.
django-autoslug/autoslug/fields.py
Line 276 in 9e39922
django-autoslug/autoslug/utils.py
Line 171 in 9e39922
I added a test showing the problem (and opened a PR by accident earlier, sorry). The test is here:https://github.com/fuzzylogic2000/django-autoslug/blob/a96382f61751912b1a7e2ae755625b5e5a0077d7/autoslug/tests/tests.py#L275
I would like to fix this. How would you prefer that I do that?
My favourite solition is to use the slugify function a second time, directly after the cropping. That would not only solve this in this case, but also when there are other future changes.
Another solution would be to rstrip
the dash or underscore.